ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-09-28 08:33:54
Exec Total Coverage
Lines: 9601 13244 72.5%
Functions: 114 143 79.7%
Branches: 7300 12353 59.1%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 430 std::map<int32_t, script_slot_data > ffcmap;
92 430 std::map<int32_t, script_slot_data > globalmap;
93 430 std::map<int32_t, script_slot_data > genericmap;
94 430 std::map<int32_t, script_slot_data > itemmap;
95 430 std::map<int32_t, script_slot_data > npcmap;
96 430 std::map<int32_t, script_slot_data > ewpnmap;
97 430 std::map<int32_t, script_slot_data > lwpnmap;
98 430 std::map<int32_t, script_slot_data > playermap;
99 430 std::map<int32_t, script_slot_data > dmapmap;
100 430 std::map<int32_t, script_slot_data > screenmap;
101 430 std::map<int32_t, script_slot_data > itemspritemap;
102 430 std::map<int32_t, script_slot_data > comboscriptmap;
103 430 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14586 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14586 return p_igetw(&unused, f);
121 }
122
123 21996 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 21989 times.
21996 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 7 output = fmt::format("{} --{}", slotname, scriptname);
129 7 break;
130 21989 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21989 output = fmt::format("{} {}", slotname, scriptname);
133 21989 }
134 21996 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 804 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 804 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 484 times.
804 if (unencrypted_result.decoded_pf)
721 320 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
484 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 484 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 484 bool compressed = unencrypted_result.compressed;
737 484 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 484 temp_name(tmpfilename);
741 char percent_done[30];
742 484 int32_t current_method=0;
743
744 PACKFILE *f;
745 484 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 484 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(strcmp(filename, "default.qst")!=0)
752 {
753 484 box_out(filename);
754 484 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 484 box_out("...");
760 484 box_eol();
761 484 box_eol();
762
763
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(encrypted)
764 {
765 484 box_out("Decrypting...");
766 484 box_save_x();
767 484 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 63 times.
484 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 484 box_out("okay.");
833 484 box_eol();
834 484 }
835 else
836 {
837 oldquest = true;
838 }
839
840 484 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
484 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
484 if(!oldquest)
864 {
865 484 delete_file(tmpfilename);
866 484 }
867
868 484 box_out("okay.");
869 484 box_eol();
870
871 484 return f;
872 804 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readmidis(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 804 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 198 times.
804 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 606 guys.setMax(255);
1132 606 items.setMax(255);
1133 606 Ewpns.setMax(255);
1134 606 Lwpns.setMax(255);
1135 606 chainlinks.setMax(255);
1136 606 decorations.setMax(255);
1137 606 particles.setMax(255);
1138 606 }
1139 else
1140 {
1141 198 guys.setMax(255);
1142 198 items.setMax(255);
1143 198 Ewpns.setMax(255);
1144 198 Lwpns.setMax(255);
1145 198 chainlinks.setMax(255);
1146 198 decorations.setMax(255);
1147 198 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 804 }
1150
1151 315 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 315 bool ret = true;
1154
1/2
✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
315 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 80640 times.
80955 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 315 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 940560 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1199 {
1200 word v_weapon_data;
1201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940560 times.
940560 if(!p_igetw(&v_weapon_data,f))
1202 return qe_invalid;
1203
1204
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetw(&(data.flags), f))
1205 return qe_invalid;
1206
1207
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.moveflags), f))
1208 return qe_invalid;
1209
1210
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetw(&(data.wflags), f))
1211 return qe_invalid;
1212
1213
2/2
✓ Branch 0 taken 4702800 times.
✓ Branch 1 taken 940560 times.
5643360 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1214 {
1215
1/2
✓ Branch 0 taken 4702800 times.
✗ Branch 1 not taken.
4702800 if (!p_getc(&(data.burnsprs[q]), f))
1216 return qe_invalid;
1217
1/2
✓ Branch 0 taken 4702800 times.
✗ Branch 1 not taken.
4702800 if (!p_getc(&(data.light_rads[q]), f))
1218 return qe_invalid;
1219 4702800 }
1220
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.glow_shape), f))
1221 return qe_invalid;
1222
1223
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.override_flags), f))
1224 return qe_invalid;
1225
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.tilew), f))
1226 return qe_invalid;
1227
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.tileh), f))
1228 return qe_invalid;
1229
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hxsz), f))
1230 return qe_invalid;
1231
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hysz), f))
1232 return qe_invalid;
1233
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hzsz), f))
1234 return qe_invalid;
1235
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hxofs), f))
1236 return qe_invalid;
1237
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.hyofs), f))
1238 return qe_invalid;
1239
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.xofs), f))
1240 return qe_invalid;
1241
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.yofs), f))
1242 return qe_invalid;
1243
1244
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetzf(&(data.step), f))
1245 return qe_invalid;
1246
1247
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.unblockable), f))
1248 return qe_invalid;
1249
1250
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetl(&(data.timeout), f))
1251 return qe_invalid;
1252
1253
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.imitate_weapon), f))
1254 return qe_invalid;
1255
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.default_defense), f))
1256 return qe_invalid;
1257
1258
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.lift_level), f))
1259 return qe_invalid;
1260
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_getc(&(data.lift_time), f))
1261 return qe_invalid;
1262
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if (!p_igetzf(&(data.lift_height), f))
1263 return qe_invalid;
1264
1265
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if(!p_igetw(&(data.script), f))
1266 return qe_invalid;
1267
2/2
✓ Branch 0 taken 7524480 times.
✓ Branch 1 taken 940560 times.
8465040 for(uint q = 0; q < 8; ++q)
1268
1/2
✓ Branch 0 taken 7524480 times.
✗ Branch 1 not taken.
7524480 if(!p_igetl(&(data.initd[q]), f))
1269 return qe_invalid;
1270
1/2
✓ Branch 0 taken 940560 times.
✗ Branch 1 not taken.
940560 if(!p_igetw(&(data.pierce_count), f))
1271 return qe_invalid;
1272 940560 return 0;
1273 940560 }
1274
1275 373 int32_t get_qst_buffers()
1276 {
1277 373 TheMaps.resize(MAPSCRS);
1278 373 old_combo_pages.resize(MAPSCRS);
1279 373 map_infos.resize(1);
1280
1281 373 Z_message("OK\n");
1282
1283 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1284 // (Shoelace's "Hero of Dreams" uses 1415.)
1285 // So let's be a bit generous and allow 4096 initially.
1286 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1287 // I tested it and it worked without flaw on 6/6/11. - L.
1288 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1289 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1290 // See https://discord.com/channels/876899628556091432/992984989073416242
1291 373 msg_strings_size = 8192;
1292
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 373 times.
373 MsgStrings = new MsgStr[msg_strings_size];
1294
1295 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1296
2/2
✓ Branch 0 taken 3055616 times.
✓ Branch 1 taken 373 times.
3055989 for(auto q = 0; q < msg_strings_size; ++q)
1297 {
1298 3055616 MsgStrings[q].clear();
1299 3055616 }
1300
1301
4/6
✓ Branch 0 taken 190976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190603 times.
✓ Branch 3 taken 373 times.
✓ Branch 4 taken 373 times.
✗ Branch 5 not taken.
190976 if((DMaps=new dmap[MAXDMAPS])==NULL)
1302 return 0;
1303
1304
1305
1306 373 combobuf.clear();
1307 373 combobuf.resize(MAXCOMBOS);
1308
1309
1310
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1311 return 0;
1312
1313 373 free_newtilebuf();
1314
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1315 return 0;
1316
1317 373 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1318 //Z_message("Performed memset on tiles\n");
1319 373 clear_tiles(newtilebuf);
1320 //Z_message("Performed clear_tiles()\n");
1321
1322
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 13 times.
373 if (get_app_id() == App::zquest)
1323 {
1324
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1325 return 0;
1326
1327 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1328 13 clear_tiles(grabtilebuf);
1329 13 }
1330
1331
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((trashbuf=(byte*)malloc(100000))==NULL)
1332 return 0;
1333
1334 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1335 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1336 // fixed by ensuring there's actually itemdata there.
1337 // If you change this, be sure to update del_qst_buffers, too.
1338
1339
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1340 return 0;
1341
1342
2/2
✓ Branch 0 taken 95861 times.
✓ Branch 1 taken 373 times.
96234 for(size_t q = 0; q < MAXITEMS+1; ++q)
1343 95861 itemsbuf[q].clear();
1344 373 itemsbuf++;
1345
1346
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1347 return 0;
1348
1349 373 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1350
1351
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1352 return 0;
1353
1354
2/2
✓ Branch 0 taken 190976 times.
✓ Branch 1 taken 373 times.
191349 for(size_t q = 0; q < MAXGUYS; ++q)
1355 190976 guysbuf[q].clear();
1356
1357
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 373 return 1;
1361 373 }
1362
1363
1364 699 void free_newtilebuf()
1365 {
1366
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 372 times.
699 if(newtilebuf)
1367 {
1368
2/2
✓ Branch 0 taken 70141500 times.
✓ Branch 1 taken 327 times.
70141827 for(int32_t i=0; i<NEWMAXTILES; i++)
1369
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 69927000 times.
140068500 if(newtilebuf[i].data)
1370 69927000 free(newtilebuf[i].data);
1371
1372 327 free(newtilebuf);
1373 327 newtilebuf = 0;
1374 327 }
1375 699 }
1376
1377 326 void free_grabtilebuf()
1378 {
1379
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 11 times.
326 if (get_app_id() == App::zquest)
1380 {
1381
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1382 {
1383
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1385
1386 11 free(grabtilebuf);
1387 11 grabtilebuf = 0;
1388 11 }
1389 11 }
1390 326 }
1391
1392 326 void del_qst_buffers()
1393 {
1394
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
326 if(MsgStrings) delete[] MsgStrings;
1395
1396
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
326 if (DMaps) delete[] DMaps;
1397
1398 326 combobuf.clear();
1399
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(colordata) free(colordata);
1401
1402 326 free_newtilebuf();
1403 326 free_grabtilebuf();
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(trashbuf) free(trashbuf);
1406
1407 // See get_qst_buffers
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(itemsbuf)
1409 {
1410 326 itemsbuf--;
1411 326 free(itemsbuf);
1412 326 }
1413
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(wpnsbuf) free(wpnsbuf);
1415
1416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(guysbuf) free(guysbuf);
1417
1418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
326 if(combo_class_buf) free(combo_class_buf);
1419 326 }
1420
1421 18 bool init_palnames()
1422 {
1423 // if(palnames==NULL)
1424 // return false;
1425
1426
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1427 {
1428
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1429 {
1430 case 0:
1431 18 sprintf(palnames[x],"Overworld");
1432 18 break;
1433
1434 case 10:
1435 18 sprintf(palnames[x],"Caves");
1436 18 break;
1437
1438 case 11:
1439 18 sprintf(palnames[x],"Passageways");
1440 18 break;
1441
1442 default:
1443 9162 sprintf(palnames[x],"%c",0);
1444 9162 break;
1445 }
1446 9216 }
1447
1448 18 return true;
1449 }
1450
1451 99629 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1452 {
1453 void *p;
1454
1455
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 p = _AL_MALLOC(MAX(size, alloc_size));
1456
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99629 times.
99629 if(!p)
1458 {
1459 return NULL;
1460 }
1461
1462
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 if(!pfread(p,size,f))
1463 {
1464 _AL_FREE(p);
1465 return NULL;
1466 }
1467
1468
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 if(pack_ferror(f))
1469 {
1470 _AL_FREE(p);
1471 return NULL;
1472 }
1473
1474 99629 return p;
1475 99629 }
1476
1477 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1478 static const byte* legacy_skip_flags;
1479
1480 /* read_midi:
1481 * Reads MIDI data from a datafile (this is not the same thing as the
1482 * standard midi file format).
1483 */
1484
1485 10210 static MIDI *read_midi(PACKFILE *f)
1486 {
1487 MIDI *m;
1488 int32_t c;
1489 10210 int16_t divisions=0;
1490 10210 int32_t len=0;
1491
1492 10210 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1493
1494
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!m)
1495 {
1496 return NULL;
1497 }
1498
1499
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1500 {
1501 326720 m->track[c].len = 0;
1502 326720 m->track[c].data = NULL;
1503 326720 }
1504
1505 10210 p_mgetw(&divisions,f);
1506 10210 m->divisions=divisions;
1507
1508
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1509 {
1510 326720 p_mgetl(&len,f);
1511 326720 m->track[c].len=len;
1512
1513
2/2
✓ Branch 0 taken 227091 times.
✓ Branch 1 taken 99629 times.
326720 if(m->track[c].len > 0)
1514 {
1515 99629 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1516
1517
1/2
✓ Branch 0 taken 99629 times.
✗ Branch 1 not taken.
99629 if(!m->track[c].data)
1518 {
1519 destroy_midi(m);
1520 return NULL;
1521 }
1522 99629 }
1523 326720 }
1524
1525 LOCK_DATA(m, sizeof(MIDI));
1526
1527
2/2
✓ Branch 0 taken 326720 times.
✓ Branch 1 taken 10210 times.
336930 for(c=0; c<MIDI_TRACKS; c++)
1528 {
1529
2/2
✓ Branch 0 taken 99629 times.
✓ Branch 1 taken 227091 times.
326720 if(m->track[c].data)
1530 {
1531 LOCK_DATA(m->track[c].data, m->track[c].len);
1532 99629 }
1533 326720 }
1534
1535 10210 return m;
1536 10210 }
1537
1538 void clear_combo(int32_t i)
1539 {
1540 combobuf[i].clear();
1541 }
1542
1543 void clear_combos()
1544 {
1545 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1546 clear_combo(tmpcounter);
1547 }
1548
1549 void pack_combos()
1550 {
1551 int32_t di = 0;
1552
1553 for(int32_t si=0; si<1024; si+=2)
1554 combobuf[di++] = combobuf[si];
1555
1556 for(; di<1024; di++)
1557 clear_combo(di);
1558 }
1559
1560 480 void reset_tunes(zctune *tune)
1561 {
1562
2/2
✓ Branch 0 taken 120960 times.
✓ Branch 1 taken 480 times.
121440 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1563 {
1564 120960 tune[i].reset();
1565 120960 }
1566 480 }
1567
1568 int32_t doortranslations_u[9][4]=
1569 {
1570 {37,38,53,54},
1571 {37,38,39,40},
1572 {37,38,55,56},
1573 {37,38,39,40},
1574 {37,38,53,54},
1575 {37,38,53,54},
1576 {37,38,53,54},
1577 {7,8,23,24},
1578 {7,8,41,42}
1579 };
1580
1581 int32_t doortranslations_d[9][4]=
1582 {
1583 {117,118,133,134},
1584 {135,136,133,134},
1585 {119,120,133,134},
1586 {135,136,133,134},
1587 {117,118,133,134},
1588 {117,118,133,134},
1589 {117,118,133,134},
1590 {151,152,167,168},
1591 {137,138,167,168},
1592 };
1593
1594 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1595 int32_t doortranslations_l[9][6]=
1596 {
1597 {66,67,82,83,98,99},
1598 {66,68,82,84,98,100},
1599 {66,69,82,85,98,101},
1600 {66,68,82,84,98,100},
1601 {66,67,82,83,98,99},
1602 {66,67,82,83,98,99},
1603 {66,67,82,83,98,99},
1604 {64,65,80,81,96,97},
1605 {64,65,80,114,96,97},
1606 };
1607
1608 int32_t doortranslations_r[9][6]=
1609 {
1610
1611 {76,77,92,93,108,109},
1612 {75,77,91,93,107,109},
1613 {74,77,90,93,106,109},
1614 {75,77,91,93,107,109},
1615 {76,77,92,93,108,109},
1616 {76,77,92,93,108,109},
1617 {76,77,92,93,108,109},
1618 {78,79,94,95,110,111},
1619 {78,79,125,95,110,111},
1620 };
1621
1622 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1623 {
1624 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1625 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1626 }
1627
1628 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1629 {
1630 //these are here to bypass compiler warnings about unused arguments
1631 840750 map=map;
1632 840750 scr=scr;
1633 840750 pos=pos;
1634
1635 //what does this function do?
1636 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1637 840750 return 2;
1638 }
1639
1640 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1641 {
1642
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1643 {
1644 18423 return 0;
1645 }
1646
1647 4425 DoorComboSet tempdcs{};
1648
1649 //up
1650
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1651 {
1652
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1653 {
1654 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1655 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1656 159300 }
1657 39825 }
1658
1659 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1660 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1661 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1662 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1663 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1664 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1665
1666 //down
1667
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1668 {
1669
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1670 {
1671 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1672 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1673 159300 }
1674 39825 }
1675
1676 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1677
1678 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1679 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1680 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1681 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1683
1684 //left
1685 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1686
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1687 {
1688
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1689 {
1690 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1691 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1692 238950 }
1693 39825 }
1694
1695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1696 {
1697 if((j!=2)&&(j!=3))
1698 {
1699 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1700 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1701 }
1702 }
1703
1704 4425 tempdcs.bombdoorcombo_l[0]=0;
1705 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1706 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1707 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1708 4425 tempdcs.bombdoorcombo_l[2]=0;
1709 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1710 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1711 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1712
1713 //right
1714
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1715 {
1716
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1717 {
1718 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1719 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1720 238950 }
1721 39825 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1724 {
1725 if((j!=2)&&(j!=3))
1726 {
1727 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1728 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1729 }
1730 }
1731
1732 4425 tempdcs.bombdoorcombo_r[0]=0;
1733 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1734 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1735 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1736 4425 tempdcs.bombdoorcombo_r[2]=0;
1737 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1738 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1739 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1740
1741 int32_t k;
1742
1743
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1744 {
1745
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1746 {
1747 4365 break;
1748 }
1749 5941 }
1750
1751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1752 {
1753 return 0;
1754 }
1755
1756
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1757 {
1758 60 DoorComboSets[k]=tempdcs;
1759 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1760 60 ++door_combo_set_count;
1761 60 }
1762
1763 4425 return k;
1764 /*
1765 doorcombo_u[9][4];
1766 doorcset_u[9][4];
1767 doorcombo_d[9][4];
1768 doorcset_d[9][4];
1769 doorcombo_l[9][6];
1770 doorcset_l[9][6];
1771 doorcombo_r[9][6];
1772 doorcset_r[9][6];
1773 bombdoorcombo_u[2];
1774 bombdoorcset_u[2];
1775 bombdoorcombo_d[2];
1776 bombdoorcset_d[2];
1777 bombdoorcombo_l[3];
1778 bombdoorcset_l[3];
1779 bombdoorcombo_r[3];
1780 bombdoorcset_r[3];
1781 walkthroughcombo[4];
1782 walkthroughcset[4];
1783 */
1784 22848 }
1785
1786 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1787 {
1788 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1789 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1790 }
1791
1792 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1793 {
1794
1795 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1796 }
1797
1798 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1799 {
1800 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1801 }
1802
1803
1804 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1805 {
1806 char temp_pwd[30];
1807 83 memset(temp_pwd,0,30);
1808
1809
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1810 {
1811 75 memcpy(temp_pwd,encrypted_pwd,30);
1812 75 temp_pwd[29]=0;
1813
1814
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1815 {
1816 2250 temp_pwd[i] -= pwdkey;
1817 2250 int32_t t=pwdkey>>15;
1818 2250 pwdkey = (pwdkey<<1)+t;
1819 2250 }
1820 75 }
1821
1822 83 memcpy(pwd,temp_pwd,30);
1823 83 }
1824
1825
1826 254 bool devpwd()
1827 {
1828 #ifdef _DEBUG
1829 return true;
1830 #endif
1831 #if DEVLEVEL > 3
1832 return true;
1833 #endif
1834
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1835 }
1836 bool check_questpwd(zquestheader *Header, char *pwd)
1837 {
1838 if(devpwd())
1839 return true;
1840 if((!strcmp(pwd, (char*)clavio)))
1841 return true;
1842 cvs_MD5Context ctx;
1843 uint8_t md5sum[16];
1844
1845 cvs_MD5Init(&ctx);
1846 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1847 cvs_MD5Final(md5sum, &ctx);
1848
1849 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1850 }
1851
1852 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1853 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1854 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1855
1856 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1857 {
1858 char keyfilename[2048];
1859 replace_extension(keyfilename, path, ext, 2047);
1860 if(!exists(keyfilename))
1861 return false;
1862 bool ret = false;
1863
1864 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1865 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1866 char msg[80] = {0};
1867 pfread(msg, 80, fp);
1868 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1869 {
1870 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1871 pack_fclose(fp);
1872 return false;
1873 }
1874 int16_t ver;
1875 byte bld;
1876 p_igetw(&ver, fp);
1877 p_getc(&bld, fp);
1878 pfread(password, QSTPWD_LEN, fp, true);
1879 if(hashed)
1880 {
1881 char unhashed_pw[QSTPWD_LEN] = {0};
1882
1883 char hashmap = 'Z';
1884 hashmap += 'Q';
1885 hashmap += 'U';
1886 hashmap += 'E';
1887 hashmap += 'S';
1888 hashmap += 'T';
1889
1890 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1891 unhashed_pw[q] = password[q] - hashmap;
1892
1893 ret = check_questpwd(Header, unhashed_pw);
1894 }
1895 else ret = check_questpwd(Header, password);
1896 pack_fclose(fp);
1897 zprint2("Found %s Key File '%s' (%s access)\n",
1898 typestr, keyfilename, ret ? "valid" : "invalid");
1899 return ret;
1900 }
1901
1902 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1903 {
1904 char exedir[PATH_MAX] = {0};
1905 extract_name(path, exedir, FILENAMEALL);
1906 char const* paths[] = {path, exedir};
1907 for(uint keyty : types)
1908 {
1909 if(keyty >= KEYFILE_NUMTY)
1910 continue;
1911 for(char const* p : paths)
1912 {
1913 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1914 return true;
1915 }
1916 }
1917 return false;
1918 }
1919
1920 481 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1921 {
1922 481 zprint2("\n");
1923 481 zprint2("[QUEST METADATA]\n");
1924
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(path)
1925 481 zprint2("Path: %s\n", path);
1926
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 122 times.
481 if(tempheader.title[0])
1927 359 zprint2("Title: %s\n", tempheader.title);
1928 481 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1929
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 283 times.
481 if(tempheader.new_version_id_date_day)
1930 198 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1931
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 214 times.
481 if(tempheader.version[0])
1932 267 zprint2("Qst Version: %s\n", tempheader.version);
1933
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 122 times.
481 if(tempheader.author[0])
1934 359 zprint2("Author: %s\n", tempheader.author);
1935 481 zprint2("\n");
1936 481 }
1937
1938 816 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1939 {
1940 int32_t dummy;
1941 816 zquestheader tempheader{};
1942
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 12 times.
816 tempheader.filename = Header->filename;
1943 char dummybuf[80];
1944 byte temp_map_count;
1945 byte temp_midi_flags[MIDIFLAGS_SIZE];
1946 word version;
1947 char temp_pwd[30], temp_pwd2[30];
1948 int16_t temp_pwdkey;
1949 cvs_MD5Context ctx;
1950 804 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1951 804 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1952
1953
1954
1955
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
804 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1956 {
1957 Z_message("Unable to read header string\n");
1958 return qe_invalid;
1959 }
1960
1961 // check header
1962
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1963 {
1964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1965 {
1966 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1967 return qe_invalid;
1968 }
1969 24 }
1970
1971 804 int32_t templatepath_len=0;
1972
1973 804 tempheader.external_zinfo = false;
1974 804 read_zinfo = false;
1975
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1976 {
1977 byte padding;
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1990
1991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1992 {
1993 return qe_version;
1994 }
1995
1996 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1997
1998
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1999 {
2000 return qe_invalid;
2001 }
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
2004 {
2005 return qe_obsolete;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2019
2020
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2021 {
2022 return qe_invalid;
2023 }
2024
2025
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2026 {
2027 return qe_invalid;
2028 }
2029
2030 24 FFCore.quest_format[qMapCount] = temp_map_count;
2031
2032
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2033 {
2034 return qe_invalid;
2035 }
2036
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2048 {
2049 return qe_invalid;
2050 }
2051
2052
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2053 {
2054 return qe_invalid;
2055 }
2056
2057
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2058 {
2059 return qe_invalid;
2060 }
2061
2062
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2063 {
2064 return qe_invalid;
2065 }
2066
2067
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2068 {
2069 return qe_invalid;
2070 }
2071
2072
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2073 {
2074 return qe_invalid;
2075 }
2076 // These fields are expected to end in null bytes!
2077 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2078
2079
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2080 {
2081 return qe_invalid;
2082 }
2083 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2084
2085
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2086 {
2087 return qe_invalid;
2088 }
2089
2090
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2091 {
2092 return qe_invalid;
2093 }
2094
2095
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2096 {
2097 return qe_invalid;
2098 }
2099
2100 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2102
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2103
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2104
2105
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2106 {
2107 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2108 // Not anymore...
2109 memset(tempheader.minver,0,17);
2110 tempheader.build=0;
2111 tempheader.use_keyfile=0;
2112 memset(tempheader.old_foo, 0, 9);
2113 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2117 {
2118 return qe_invalid;
2119 }
2120
2121
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2122 {
2123 return qe_invalid;
2124 }
2125
2126 24 FFCore.quest_format[vBuild] = tempheader.build;
2127
2128
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2134 {
2135 return qe_invalid;
2136 }
2137 } // starting at minver
2138
2139
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2140 {
2141 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2142 6 }
2143 else
2144 {
2145
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at rules3
2148 }
2149
2150
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2151 {
2152
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2153 12 }
2154 }
2155
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2156
2157
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2158
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2159 {
2160
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2161
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2162
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2163 18 }
2164
2165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2166 {
2167 6 byte *mf=temp_midi_flags;
2168
2169
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2170 {
2171 4 mf=(byte*)dummybuf;
2172 4 }
2173
2174
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2175 {
2176 return qe_invalid; // starting at foo2
2177 }
2178
2179
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2180 {
2181 return qe_invalid; // starting at foo2
2182 }
2183 6 }
2184
2185
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2186
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2187 {
2188 18 memset(tempheader.templatepath,0,2048);
2189 18 }
2190 else
2191 {
2192 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2193 {
2194 return qe_invalid;
2195 }
2196 }
2197
2198
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2199
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2200 {
2201 24 tempheader.use_keyfile=0;
2202 24 }
2203 24 }
2204 else
2205 {
2206 //section id
2207
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_mgetl(&dummy,f))
2208 {
2209 return qe_invalid;
2210 }
2211
2212 //section version info
2213
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&version,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if (version > V_HEADER)
2219 return qe_version;
2220
2221 780 FFCore.quest_format[vHeader] = version;
2222
2223
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&dummy,f))
2224 {
2225 return qe_invalid;
2226 }
2227
2228 //section size
2229
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetl(&dummy,f))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 //finally... section data
2235
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&tempheader.zelda_version,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 780 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2241
2242 //do some quick checking...
2243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(tempheader.zelda_version > ZELDA_VERSION)
2244 {
2245 return qe_version;
2246 }
2247
2248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2249 {
2250 return qe_invalid;
2251 }
2252
2253
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(bad_version(tempheader.zelda_version))
2254 {
2255 return qe_obsolete;
2256 }
2257
2258
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.build,f))
2259 {
2260 return qe_invalid;
2261 }
2262
2263 780 FFCore.quest_format[vBuild] = tempheader.build;
2264
2265
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 721 times.
780 if(version<3)
2266 {
2267
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2268 {
2269 return qe_invalid;
2270 }
2271
2272
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2273 {
2274 return qe_invalid;
2275 }
2276
2277 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2278
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2279
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2280
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2281 59 }
2282 else
2283 {
2284
2/4
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 721 times.
✗ Branch 3 not taken.
721 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2285 {
2286 return qe_invalid;
2287 }
2288 }
2289
2290
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_igetw(&tempheader.internal,f))
2291 {
2292 return qe_invalid;
2293 }
2294
2295
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.quest_number,f))
2296 {
2297 return qe_invalid;
2298 }
2299
2300 780 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2301
2302 780 size_t versz = version < 8 ? 9 : 16;
2303
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.version,versz,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2309 //needs to be copied as char[9] or stored as a s.str
2310
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.minver,versz,f))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2316
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2317 {
2318 return qe_invalid;
2319 }
2320 780 tempheader.title[sizeof(tempheader.title)-1] = 0;
2321
2322
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2323 {
2324 return qe_invalid;
2325 }
2326 780 tempheader.author[sizeof(tempheader.author)-1] = 0;
2327
2328
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.use_keyfile,f))
2329 {
2330 return qe_invalid;
2331 }
2332
2333 /*
2334 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2335 {
2336 return qe_invalid;
2337 }
2338 */
2339
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2340 {
2341 return qe_invalid;
2342 }
2343
2344
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(&dummybuf,4,f))
2345 {
2346 return qe_invalid;
2347 }
2348
2349
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(dummybuf,14,f))
2355 {
2356 return qe_invalid;
2357 }
2358
2359 780 templatepath_len=sizeof(tempheader.templatepath);
2360
2361
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 59 times.
780 if(version==1)
2362 {
2363 59 templatepath_len=280;
2364 59 }
2365
2366
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!pfread(tempheader.templatepath,templatepath_len,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2371
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_getc(&temp_map_count,f))
2372 {
2373 return qe_invalid;
2374 }
2375
2376
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if(version>=4)
2377 {
2378
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.version_major,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.version_minor,f))
2383 {
2384 return qe_invalid;
2385 }
2386
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.version_patch,f))
2387 {
2388 return qe_invalid;
2389 }
2390
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2391 {
2392 return qe_invalid;
2393 }
2394
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2395 {
2396 return qe_invalid;
2397 }
2398
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_beta,f))
2399 {
2400 return qe_invalid;
2401 }
2402
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2403 {
2404 return qe_invalid;
2405 }
2406
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.new_version_id_release,f))
2407 {
2408 return qe_invalid;
2409 }
2410
2411 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2412
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2413 tempheader.version_minor = 55;
2414
2415
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2416 {
2417 return qe_invalid;
2418 }
2419
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_month,f))
2420 {
2421 return qe_invalid;
2422 }
2423
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_day,f))
2424 {
2425 return qe_invalid;
2426 }
2427
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2436
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.new_version_devsig,256,f))
2437 {
2438 return qe_invalid;
2439 }
2440
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2441 strcpy(tempheader.new_version_devsig, "EmilyV99");
2442
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.new_version_compilername,256,f))
2443 {
2444 return qe_invalid;
2445 }
2446
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.new_version_compilerversion,256,f))
2447 {
2448 return qe_invalid;
2449 }
2450
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.product_name,1024,f))
2451 {
2452 return qe_invalid;
2453 }
2454
2455
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&tempheader.compilerid,f))
2456 {
2457 return qe_invalid;
2458 }
2459
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2460 {
2461 return qe_invalid;
2462 }
2463
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2468 {
2469 return qe_invalid;
2470 }
2471
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2472 {
2473 return qe_invalid;
2474 }
2475
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetw(&tempheader.developerid,f))
2476 {
2477 return qe_invalid;
2478 }
2479
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.made_in_module_name,1024,f))
2480 {
2481 return qe_invalid;
2482 }
2483
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.build_datestamp,256,f))
2484 {
2485 return qe_invalid;
2486 }
2487
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.build_timestamp,256,f))
2488 {
2489 return qe_invalid;
2490 }
2491 198 }
2492 else // <4
2493 {
2494 582 tempheader.version_major = 0;
2495 582 tempheader.version_minor = 0;
2496 582 tempheader.version_patch = 0;
2497 582 tempheader.new_version_id_fourth = 0;
2498 582 tempheader.new_version_id_alpha = 0;
2499 582 tempheader.new_version_id_beta = 0;
2500 582 tempheader.new_version_id_gamma = 0;
2501 582 tempheader.new_version_id_release = 0;
2502 582 tempheader.new_version_id_date_year = 0;
2503 582 tempheader.new_version_id_date_month = 0;
2504 582 tempheader.new_version_id_date_day = 0;
2505 582 tempheader.new_version_id_date_hour = 0;
2506 582 tempheader.new_version_id_date_minute = 0;
2507
2508 582 memset(tempheader.new_version_devsig, 0, 256);
2509 582 memset(tempheader.new_version_compilername, 0, 256);
2510 582 memset(tempheader.new_version_compilerversion, 0, 256);
2511 582 memset(tempheader.product_name, 0, 1024);
2512 582 strcpy(tempheader.product_name, "ZQuest Classic");
2513
2514 582 tempheader.compilerid = 0;
2515 582 tempheader.compilerversionnumber_first = 0;
2516 582 tempheader.compilerversionnumber_second = 0;
2517 582 tempheader.compilerversionnumber_third = 0;
2518 582 tempheader.compilerversionnumber_fourth = 0;
2519 582 tempheader.developerid = 0;
2520
2521 582 memset(tempheader.made_in_module_name, 0, 1024);
2522 582 memset(tempheader.build_datestamp, 0, 256);
2523 582 memset(tempheader.build_timestamp, 0, 256);
2524 }
2525
2526
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if ( version >= 5 )
2527 {
2528
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(tempheader.build_timezone,6,f))
2529 {
2530 return qe_invalid;
2531 }
2532 198 }
2533 else // < 5
2534 {
2535 582 memset(tempheader.build_timezone, 0, 6);
2536 }
2537
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if ( version >= 6 )
2538 {
2539 byte b;
2540
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&b,f))
2541 {
2542 return qe_invalid;
2543 }
2544 198 tempheader.external_zinfo = b?true:false;
2545 198 read_zinfo = true;
2546 198 }
2547
2548
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 582 times.
780 if(version >= 7)
2549 {
2550
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2551 {
2552 return qe_invalid;
2553 }
2554 198 }
2555 else
2556 {
2557 582 tempheader.new_version_is_nightly = false;
2558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 582 times.
582 if(tempheader.zelda_version < 0x255)
2559 {
2560
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
582 switch(tempheader.zelda_version)
2561 {
2562 case 0x254:
2563 tempheader.version_major = 2;
2564 tempheader.version_minor = 54;
2565 break;
2566 case 0x250:
2567
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 404 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 13 times.
523 switch(tempheader.build)
2568 {
2569 case 19:
2570 tempheader.version_major = 2;
2571 tempheader.version_minor = 50;
2572 tempheader.new_version_id_gamma = 1;
2573 break;
2574 case 20:
2575 tempheader.version_major = 2;
2576 tempheader.version_minor = 50;
2577 tempheader.new_version_id_gamma = 2;
2578 break;
2579 case 21:
2580 tempheader.version_major = 2;
2581 tempheader.version_minor = 50;
2582 tempheader.new_version_id_gamma = 3;
2583 break;
2584 case 22:
2585 tempheader.version_major = 2;
2586 tempheader.version_minor = 50;
2587 tempheader.new_version_id_gamma = 4;
2588 break;
2589 case 23:
2590 tempheader.version_major = 2;
2591 tempheader.version_minor = 50;
2592 tempheader.new_version_id_gamma = 5;
2593 break;
2594 case 24:
2595 31 tempheader.version_major = 2;
2596 31 tempheader.version_minor = 50;
2597 31 tempheader.new_version_id_release = -1;
2598 31 break;
2599 case 25:
2600 tempheader.version_major = 2;
2601 tempheader.version_minor = 50;
2602 tempheader.version_patch = 1;
2603 tempheader.new_version_id_gamma = 1;
2604 break;
2605 case 26:
2606 24 tempheader.version_major = 2;
2607 24 tempheader.version_minor = 50;
2608 24 tempheader.version_patch = 1;
2609 24 tempheader.new_version_id_gamma = 2;
2610 24 break;
2611 case 27:
2612 tempheader.version_major = 2;
2613 tempheader.version_minor = 50;
2614 tempheader.version_patch = 1;
2615 tempheader.new_version_id_gamma = 3;
2616 break;
2617 case 28:
2618 6 tempheader.version_major = 2;
2619 6 tempheader.version_minor = 50;
2620 6 tempheader.version_patch = 1;
2621 6 tempheader.new_version_id_release = -1;
2622 6 break;
2623 case 29:
2624 404 tempheader.version_major = 2;
2625 404 tempheader.version_minor = 50;
2626 404 tempheader.version_patch = 2;
2627 404 tempheader.new_version_id_release = -1;
2628 404 break;
2629 case 30:
2630 tempheader.version_major = 2;
2631 tempheader.version_minor = 50;
2632 tempheader.version_patch = 3;
2633 tempheader.new_version_id_gamma = 1;
2634 break;
2635 case 31:
2636 16 tempheader.version_major = 2;
2637 16 tempheader.version_minor = 53;
2638 16 tempheader.new_version_id_gamma = -1;
2639 16 break;
2640 case 32:
2641 29 tempheader.version_major = 2;
2642 29 tempheader.version_minor = 53;
2643 29 tempheader.new_version_id_release = -1;
2644 29 break;
2645 case 33:
2646 13 tempheader.version_major = 2;
2647 13 tempheader.version_minor = 53;
2648 13 tempheader.version_patch = 1;
2649 13 break;
2650 }
2651 523 break;
2652
2653 case 0x211:
2654 tempheader.version_major = 2;
2655 tempheader.version_minor = 11;
2656 tempheader.new_version_id_beta = tempheader.build;
2657 break;
2658 case 0x210:
2659 59 tempheader.version_major = 2;
2660 59 tempheader.version_minor = 10;
2661 59 tempheader.new_version_id_beta = tempheader.build;
2662 59 break;
2663 }
2664 582 }
2665 }
2666
2667
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 626 times.
780 if (version>=9)
2668 {
2669 154 std::string version_string;
2670
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 if(!p_getcstr(&version_string, f))
2671 {
2672 return qe_invalid;
2673 }
2674
2675 154 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2676 154 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 }
2678 else
2679 {
2680 626 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2681 }
2682 }
2683
2684
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 747 times.
804 if(printmetadata)
2685 {
2686
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2687 57 }
2688
2689 //{ Version Warning
2690
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 int32_t vercmp = tempheader.compareVer();
2691
3/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 804 times.
✗ Branch 5 not taken.
804 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2692
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804 times.
✗ Branch 3 not taken.
804 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2693
4/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 154 times.
958 if(vercmp > 0 || (!vercmp &&
2694
2/4
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 154 times.
✗ Branch 3 not taken.
154 (astatecmp > 0 || (!astatecmp &&
2695 154 avercmp > 0))))
2696 {
2697 bool r = true;
2698 if(loadquest_report)
2699 {
2700 enter_sys_pal();
2701 AlertDialog("Quest saved in newer version",
2702 "This quest was last saved in a newer version of ZQuest."
2703 " Attempting to load this quest may not work correctly; to"
2704 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2705 "\n\nWould you like to continue loading anyway? (Not recommended)",
2706 [&](bool ret,bool)
2707 {
2708 r = ret;
2709 }).show();
2710 exit_sys_pal();
2711 }
2712 if(!r)
2713 return qe_silenterr;
2714 }
2715 //}
2716
2717 804 read_ext_zinfo = tempheader.external_zinfo;
2718
2719
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 *Header = tempheader;
2720 804 map_count=temp_map_count;
2721 804 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2722
2723
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 unpack_qrs();
2724
2725 804 return 0;
2726 828 }
2727
2728 10424 int32_t readrules(PACKFILE *f, zquestheader *Header)
2729 {
2730
2/2
✓ Branch 0 taken 10401 times.
✓ Branch 1 taken 23 times.
10424 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10424 times.
10424 if (should_skip)
2732 return 0;
2733
2734 int32_t dummy;
2735 10424 zquestheader tempheader = *Header;
2736 10424 word s_version=0;
2737 10424 dword compatrule_version=0;
2738
2739
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 9967 times.
10424 if(tempheader.zelda_version >= 0x193)
2740 {
2741 //section version info
2742
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
2743 {
2744 return qe_invalid;
2745 }
2746
2747
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (s_version > V_RULES)
2748 return qe_version;
2749
2750 457 FFCore.quest_format[vRules] = s_version;
2751
2752
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dummy,f))
2753 {
2754 return qe_invalid;
2755 }
2756
2757
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 259 times.
457 if(s_version > 16)
2758 {
2759
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!p_igetl(&compatrule_version,f))
2760 {
2761 return qe_invalid;
2762 }
2763 198 }
2764 457 FFCore.quest_format[vCompatRule] = compatrule_version;
2765
2766 //section size
2767
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
2768 {
2769 return qe_invalid;
2770 }
2771
2772
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 198 times.
457 if ( s_version < 15 )
2773 {
2774 //finally... section data
2775
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2776 {
2777 return qe_invalid;
2778 }
2779 259 }
2780 else
2781 {
2782
2783
2/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2784 {
2785 return qe_invalid;
2786 }
2787
2788 }
2789 457 }
2790
2791 //{ bunch of compat stuff
2792 10424 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2793
2794
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 9944 times.
10424 unpack_qrs();
2795
2796
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<2)
2797 {
2798
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2799
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2800
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2801
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2802
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2803
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2804
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2805
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2806
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2807
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2809
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2810
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2811
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2812
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2813
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2814
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2815
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2816
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2817 82 }
2818
2819 //Now, do any updates...
2820
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
480 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2821 {
2822
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2823
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2824
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2825
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2826
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2827 82 }
2828
2829
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2830 {
2831
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2832 23 }
2833
2834
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2835 {
2836
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2837 23 }
2838
2839
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
480 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2840 {
2841
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2842 23 }
2843
2844
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version <= 0x210)
2845 {
2846
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2847 82 }
2848
2849
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 421 times.
480 if(tempheader.zelda_version == 0x210)
2850 {
2851
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2852
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2853
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2854 59 }
2855
2856
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version <= 0x210)
2857 {
2858
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2859
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2860 82 }
2861
2862 //might not be correct
2863
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(tempheader.zelda_version < 0x210)
2864 {
2865
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2866
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2867
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2868 23 }
2869
2870
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version < 0x211)
2871 {
2872
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2873 82 }
2874
2875
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 475 times.
480 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2876 {
2877
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 458 times.
480 set_qr(qr_192b163_WARP,1);
2878 22 }
2879
2880
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 49 times.
22 if(tempheader.zelda_version == 0x210)
2881 {
2882
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2883
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2884
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2885 59 }
2886
2887
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
108 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2888 {
2889
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 set_qr(qr_OLDPICKUP,1);
2890 82 }
2891
2892
3/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
480 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2893 {
2894
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2895
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2896 82 }
2897
2898
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2899 {
2900
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2901 82 }
2902
2903
4/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 169 times.
480 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2904 {
2905
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_PEAHATCLOCKVULN, 1);
2906 31 }
2907
2908
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
480 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2909 {
2910
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 set_qr(qr_OLD_DOORREPAIR, 1);
2911 82 }
2912
2913
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
280 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2914 {
2915
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 236 times.
318 set_qr(qr_OLD_SECRETMONEY, 1);
2916 82 }
2917
2918
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
280 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2919 {
2920
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 181 times.
318 set_qr(qr_OLD_POTION_OR_HC, 1);
2921 137 }
2922
2923
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
335 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2924 {
2925
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 126 times.
263 set_qr(qr_OFFSCREENWEAPONS, 1);
2926 137 }
2927
2928 //Bombchu fix.
2929
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 200 times.
335 if(tempheader.zelda_version == 0x250)
2930 {
2931
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 169 times.
200 if ( tempheader.build == 24 ) //2.50.0
2932 {
2933
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2934 31 }
2935
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 194 times.
200 if ( tempheader.build == 28 ) //2.50.1
2936 {
2937
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2938 6 }
2939
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 119 times.
200 if ( tempheader.build == 29 ) //2.50.2
2940 {
2941
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2942 81 }
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if ( tempheader.build == 30 ) //2.50.3RC1
2944 {
2945 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2946 }
2947 200 }
2948
2949
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
345 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2950 {
2951 // qr_OFFSETEWPNCOLLISIONFIX
2952 // All 'official' quests need this disabled.
2953 // All 2.10 and lower quests need this enabled to preseve compatability.
2954 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2955
2956 //~Gleeok
2957
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 110 times.
253 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2958
2959 // Broke in build 695
2960
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
143 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2961
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 set_qr(qr_BROKENSTATUES, 1);
2962 143 }
2963
11/14
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 462 times.
✓ Branch 2 taken 457 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 578 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 578 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 561 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
341 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2964 {
2965
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2966 22 }
2967
8/8
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 383 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 198 times.
✓ Branch 7 taken 13 times.
583 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2968 {
2969
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 301 times.
570 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2970 269 }
2971
2972
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2973 {
2974
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2975 82 }
2976
2977
4/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
282 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2978 {
2979
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 112 times.
170 set_qr(qr_STEP_IS_FLOAT,0);
2980 282 }
2981
2982
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if ( tempheader.zelda_version < 0x250 )
2983 {
2984
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2985 82 }
2986
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version < 3)
2988 {
2989
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2990
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2991 82 }
2992
2993
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<4)
2994 {
2995
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2996 82 }
2997
2998
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<5)
2999 {
3000
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
3001 82 }
3002
3003
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<6)
3004 {
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
3006 82 }
3007
3008
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<7) // January 2008
3009 {
3010
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
3011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3012 82 }
3013
3014
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<8)
3015 {
3016
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3017 82 }
3018 else
3019 {
3020
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 set_bit(deprecated_rules, 12, 0);
3021 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<9) // October 2008
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3026
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3027
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3028
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3029 82 }
3030
3031
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<10) // December 2008
3032 {
3033
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3034
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3035 82 }
3036
3037
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version<11) // April 2009
3038 {
3039
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3040 82 }
3041
3042 // This served no purpose.
3043 // if(s_version<12) // December 2009
3044 // {
3045 // set_qr(qr_BRKBLSHLDS_DEP,0);
3046 // set_qr(qr_OLDTRIBBLES_DEP,0);
3047 // }
3048
3049 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3050
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(s_version < 13)
3051 {
3052
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3053 82 }
3054
3055 // Not entirely sure this is the best place for this...
3056 //2.50.2 bitmap offset fix
3057 480 memset(extra_rules, 0, EXTRARULES_SIZE);
3058
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
480 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3059 {
3060
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 139 times.
282 set_er(er_BITMAPOFFSET, 1);
3061
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 set_qr(qr_BITMAPOFFSETFIX, 1);
3062 143 }
3063 //required because quest templates also used this bit, although
3064 //it never did anything, before. -Z
3065
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 151 times.
341 if ( tempheader.zelda_version == 0x250 )
3066 {
3067
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 103 times.
200 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3068 {
3069
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_er(er_BITMAPOFFSET, 0);
3070
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_qr(qr_BITMAPOFFSETFIX, 0);
3071 97 }
3072 200 }
3073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 if ( tempheader.zelda_version == 0x254 )
3074 {
3075 set_er(er_BITMAPOFFSET, 0);
3076 set_qr(qr_BITMAPOFFSETFIX, 0);
3077 }
3078
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
351 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3079 {
3080 set_er(er_BITMAPOFFSET, 0);
3081 set_qr(qr_BITMAPOFFSETFIX, 0);
3082 }
3083 //optimise fast drawing for older versions.
3084
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 153 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
351 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3085 {
3086
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 107 times.
351 set_qr(qr_OLDSPRITEDRAWS, 1);
3087 282 }
3088 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3089 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3090 //older quests can set the rule by hand. We need a new qst.dat again.
3091
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 set_qr(qr_OLDEWPNPARENT, 1);
3094 }
3095
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3096 {
3097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3098 }
3099
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3100 {
3101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 set_qr(qr_OLDQUESTMISC, 1);
3102 }
3103
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3104 {
3105
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3106
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDEWPNPARENT, 0);
3107
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDQUESTMISC, 0);
3108 282 }
3109
3110 //item scripts continue to run
3111
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3112 {
3113
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3114
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3115
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3116
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3117
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3118
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3119
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3120 282 }
3121
3122
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3123 {
3124
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3125 282 }
3126
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3127 {
3128
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_TRACESCRIPTIDS, 0);
3129
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3130
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3131
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_250DIVISION,1);
3132
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3133
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3134
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_FORCE_INLINE,0);
3135
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BINARY_32BIT,0);
3136
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 274 times.
282 if ( get_qr(qr_SELECTAWPN) )
3137 {
3138
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3139 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3140 //Now they **do**, unless you disable that behaviour.
3141 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3142 //now enable the disable L/R item swap on load.
3143 8 }
3144
3145 282 }
3146
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3147 {
3148 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3149
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3150 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3151 //animations ending earlier than they should.
3152
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3153 //Enemies would ignore solidity on the top half of combos
3154
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3155 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3156
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3157 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3158
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3159 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3160
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3161 282 }
3162
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x255 )
3163 {
3164
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOFFCWAITDRAW, 1);
3165
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOITEMWAITDRAW, 1);
3166
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3167
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3168 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3169 282 }
3170
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3171 {
3172
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3173 282 }
3174
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3175 {
3176
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_OLD_PRINTF_ARGS, 1);
3177 282 }
3178
3179
3180
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3181 {
3182
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_BROKEN_RING_POWER, 1);
3183 282 }
3184
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3185 {
3186
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3187 282 }
3188
5/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✓ Branch 5 taken 86 times.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3189 {
3190
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3191 282 }
3192
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
368 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3193 {
3194 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
368 if(get_qr(qr_SET_XBUTTON_ITEMS))
3196 set_qr(qr_SET_YBUTTON_ITEMS,1);
3197 282 }
3198
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3199 {
3200
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3201 282 }
3202
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3203 {
3204
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_OLD_CHEST_COLLISION,1);
3205 282 }
3206
3207
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3208 {
3209
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3210 282 }
3211 //Sideview spikes in 2.50.0
3212
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
282 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3213 {
3214
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 187 times.
324 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3215 137 }
3216 //more 2.50 fixes -Z
3217
4/4
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 198 times.
335 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3218 {
3219
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 49 times.
263 set_qr(qr_MELEEMAGICCOST, 0);
3220
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3221
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_OLDMIRRORCOMBOS, 1);
3222
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENBOOKCOST, 1);
3223
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENCHARINTDRAWING, 1);
3224
3225 224 }
3226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
422 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3227 {
3228 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3229 set_qr(qr_MELEEMAGICCOST, 1);
3230 }
3231
3232
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 399 times.
422 if(tempheader.zelda_version < 0x193)
3233 {
3234
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3235 23 }
3236
3237
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 140 times.
422 if(tempheader.zelda_version < 0x255)
3238 {
3239
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDINFMAGIC, 1);
3240 282 }
3241
3242
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 340 times.
422 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3243 {
3244
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3245 82 }
3246
3247
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
422 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3248 {
3249
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 140 times.
422 set_qr(qr_OLD_F6,1);
3250 282 }
3251
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3252 {
3253
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3254 282 }
3255
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3256 {
3257
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3258 282 }
3259
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3260 {
3261
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 86 times.
368 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3262 282 }
3263 //}
3264
3265
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3266
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3267
3268
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 2) //Old CSet2 Handling
3269
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCS2,1);
3270
3271
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3272
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3273
3274
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3275
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3276
3277
3/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 82 times.
282 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3278
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3279
3280
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3281
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3282
3283
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3284
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3285
3286
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3287
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3288
3289
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 9)
3290 {
3291 //Hardcoded BS Patras
3292
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_BS_PATRA,1);
3293 //Hardcoded Patra Inner Eye offsets
3294
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3295 //Broken 'Big enemy' animation style
3296
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3297 //Broken Attribute 31/32
3298
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3299 282 }
3300
3301
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 10) //Shared candle use limits
3302
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3303
3304
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 11) //No cross-screen return points
3305
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_RESPAWN_POINTS,1);
3306
3307
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 12)
3308 {
3309 //Old fire trail duration
3310
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3311 //Old Intro String in Ganon Room Behavior
3312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3313
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_GANONINTRO,1);
3314 282 }
3315
3316
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
282 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3317 set_qr(qr_ANONE_NOANIM,1);
3318
3319
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 14) //Old Bridge Combo Behavior
3320
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3321
3322
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 15) //Broken Z3 Animation
3323
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3324
3325
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3326
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3327
3328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 17)
3329 {
3330 //Old Quake/DrawYOffset behavior
3331 //set_qr(qr_OLD_DRAWOFFSET,1);
3332 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3333 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3334 282 }
3335
3336
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 18)
3337 {
3338 //Broken DrawScreen Derivative Functions
3339
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3340 //Scrolling Cancels Charge
3341
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3342 282 }
3343
3344
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3345
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3346
3347
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 20)
3348
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3349
3350
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 21)
3351 {
3352
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3353
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3354
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3355
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BUG_NET,1);
3356
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3357 282 }
3358
3359
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 22)
3360
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3361
3362
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 23)
3363
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_HALF_MAGIC,1);
3364
3365
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 24)
3366 {
3367
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3368
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3369 282 }
3370
3371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 25)
3372 {
3373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3374
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3375
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3376 282 }
3377
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 26)
3378 {
3379
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3380
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_POLVIRE_NO_SHADOW,1);
3381
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3382 282 }
3383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3384 {
3385
2/2
✓ Branch 0 taken 84882 times.
✓ Branch 1 taken 282 times.
85164 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3386
1/2
✓ Branch 0 taken 84882 times.
✗ Branch 1 not taken.
84882 set_qr(q,0);
3387
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 282 times.
1974 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3388
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 set_qr(q,0);
3389 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3390 282 }
3391
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
282 if(compatrule_version < 28)
3392
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3393
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 29)
3394
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3395
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 30)
3396 {
3397
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DECO_2_YOFFSET,1);
3398
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCREENSTATE_80s_BUG,1);
3399 287 }
3400
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 31)
3401 {
3402
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3403
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3404 287 }
3405
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 32)
3406
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3407
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 33)
3408
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NO_LIFT_SPRITE,1);
3409
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 34)
3410 {
3411
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3412
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3413
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3414
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3415 287 }
3416
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 35)
3417 {
3418
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3419
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3420 289 }
3421
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 5 times.
294 if(compatrule_version < 36)
3422
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_OLD_SHALLOW_SFX,1);
3423
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
294 if(compatrule_version < 37)
3424
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3425
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 38)
3426
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3427
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 39)
3428
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3429
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 40)
3430
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3431
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
296 if(compatrule_version < 41)
3432
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKENHITBY,1);
3433
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 42)
3434
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3435
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 43)
3436
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_BOMB_HITBOXES,1);
3437
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 44)
3438
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3439
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 45)
3440
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3441
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 46)
3442
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3443
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 47)
3444 {
3445
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3446
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3447 299 }
3448
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 48)
3449
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GUY_HANDLING,1);
3450
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 49)
3451
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3452
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 50)
3453
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3454
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 51)
3455
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3456
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if (compatrule_version < 52)
3457
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3458
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 53)
3459 {
3460
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SUBSCR,1);
3461
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3462
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3463 299 }
3464
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 54)
3465
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3466
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 55)
3467
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3468
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 56)
3469
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3470
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 57)
3471
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3472
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 58)
3473
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3474
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 59)
3475
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3476
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 60)
3477
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3478
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 61)
3479
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3480
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 3 times.
302 if(compatrule_version < 62)
3481
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3482
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 2 times.
302 if(compatrule_version < 63)
3483 {
3484
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_LIFTSWIM,1);
3485
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3486 300 }
3487
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 2 times.
302 if(compatrule_version < 64)
3488
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3489
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 23 times.
302 if(compatrule_version < 65)
3490
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3491
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 66)
3492
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3493
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 67)
3494
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3495
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 68)
3496
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3497
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if(compatrule_version < 69)
3498
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3499
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 70)
3500
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_CONVEYORS, 1);
3501
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 71)
3502
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3503
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 72)
3504
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3505
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
348 if (compatrule_version < 73)
3506 {
3507
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_LANDING_SFX, 1);
3508
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3509 327 }
3510
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
348 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3511
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3512
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 347 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
674 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3513
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3514
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 673 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1000 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3515
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3516
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 77)
3517
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3518
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 78)
3519
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3520
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 79)
3521
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3522
2/2
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 981 times.
1326 if (compatrule_version < 80)
3523
1/2
✓ Branch 0 taken 345 times.
✗ Branch 1 not taken.
345 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3524
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1326 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3525
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3526
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1301 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1652 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3527
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3528
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1627 times.
1978 if (compatrule_version < 82)
3529 {
3530
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3531
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3532 351 }
3533
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1627 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1978 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3534
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3535
5/6
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1953 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2304 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3536
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 326 times.
25 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3537
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2278 times.
2630 if (compatrule_version < 85)
3538
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_OLD_WEAPON_REFLECTION, 1);
3539
5/6
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2278 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2630 if (compatrule_version < 86 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3540
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 326 times.
26 set_qr(qr_OLD_SPRITE_FALL_DROWN, 1);
3541
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2604 times.
2956 if (compatrule_version < 87)
3542
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_OLD_TERMINAL_VELOCITY, 1);
3543
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2604 times.
2956 if (compatrule_version < 88)
3544
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_OLD_SCRIPT_LEVEL_GLOBAL_STATES, 1);
3545
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2604 times.
2956 if (compatrule_version < 89)
3546
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_BROKEN_ARMOS_GRAVE_BIGHITBOX_COLLISION, 1);
3547
3548
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2604 times.
2956 if (compatrule_version < 90)
3549 {
3550
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_CLASSIC_DRAWING_ORDER, 1);
3551
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 set_qr(qr_OLD_WEAPON_DRAW_ANIMATE_TIMING, 1);
3552 352 }
3553
3554
2/2
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 2602 times.
2956 if (compatrule_version < 91)
3555 {
3556
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 set_qr(qr_OLD_SCRIPTS_INTERNAL_ARRAYS_BOUND_INDEX, 1);
3557
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 set_qr(qr_OLD_SCRIPTS_ARRAYS_NON_ZERO_DEFAULT_VALUE, 1);
3558 354 }
3559
3560
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 2476 times.
2956 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3561
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 198 times.
480 if (s_version < 16)
3562
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3563
3564
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 *Header = tempheader;
3565
3566 480 return 0;
3567 20368 }
3568
3569 4072985 void init_msgstr(MsgStr *str)
3570 {
3571
2/4
✓ Branch 0 taken 4072985 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4072985 times.
4072985 str->setFromLegacyEncoding("");
3572 4072985 str->nextstring=0;
3573 4072985 str->tile=0;
3574 4072985 str->cset=0;
3575 4072985 str->trans=false;
3576 4072985 str->font=font_zfont;
3577 4072985 str->y=32;
3578 4072985 str->sfx=18;
3579 4072985 str->listpos=0;
3580 4072985 str->x=24;
3581 4072985 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3582 4072985 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3583 4072985 str->hspace=0;
3584 4072985 str->vspace=0;
3585 4072985 str->stringflags=0;
3586 4072985 str->margins[up] = 8;
3587 4072985 str->margins[down] = 0;
3588 4072985 str->margins[left] = 8;
3589 4072985 str->margins[right] = 8;
3590 4072985 str->portrait_tile = 0;
3591 4072985 str->portrait_cset = 0;
3592 4072985 str->portrait_x = 0;
3593 4072985 str->portrait_y = 0;
3594 4072985 str->portrait_tw = 1;
3595 4072985 str->portrait_th = 1;
3596 4072985 str->shadow_type = 0;
3597 4072985 str->shadow_color = 0;
3598 4072985 str->drawlayer = 6;
3599 4072985 }
3600
3601 480 void init_msgstrings(int32_t start, int32_t end)
3602 {
3603
2/4
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
480 if(end <= start || end-start > msg_strings_size)
3604 return;
3605
3606
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 3932160 times.
3932640 for(int32_t i=start; i<end; i++)
3607 {
3608 3932160 init_msgstr(&MsgStrings[i]);
3609 3932160 MsgStrings[i].listpos=i;
3610 3932160 }
3611
3612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(start==0)
3613 {
3614
2/4
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 480 times.
480 MsgStrings[0].setFromLegacyEncoding("(None)");
3615 480 MsgStrings[0].listpos = 0;
3616 480 }
3617 480 }
3618
3619 481 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3620 {
3621
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3622
3623 481 MsgStr tempMsgString;
3624
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 init_msgstr(&tempMsgString);
3625
3626 481 word temp_msg_count=0;
3627 word temp_expansion[16];
3628 481 memset(temp_expansion, 0, 16*sizeof(word));
3629 481 char buf[8193] = {0};
3630
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(Header->zelda_version < 0x193)
3631 {
3632 byte tempbyte;
3633 24 int32_t strings_to_read=0;
3634
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3635
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3636
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3637
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3638 {
3639 18 strings_to_read=128;
3640 18 temp_msg_count=Header->old_str_count;
3641
3642 // Some sort of string count corruption seems to be common in old quests
3643
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3644 {
3645 temp_msg_count=128;
3646 }
3647 18 }
3648
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3649 {
3650 strings_to_read=255;
3651 temp_msg_count=Header->old_str_count;
3652 }
3653 else
3654 {
3655
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3656 {
3657 return qe_invalid;
3658 }
3659
3660 6 strings_to_read=temp_msg_count;
3661
3662
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3663 {
3664 Z_message("Reallocating string buffer...\n");
3665
3666 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3667 // return qe_nomem;
3668
3669 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3670 delete[] MsgStrings;
3671 MsgStrings = new MsgStr[MAXMSGS];
3672 msg_strings_size = MAXMSGS;
3673 for(auto q = 0; q < msg_strings_size; ++q)
3674 {
3675 MsgStrings[q].clear();
3676 }
3677 }
3678 }
3679
3680 //reset the message strings
3681
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3682
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3683
3684
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3685 {
3686
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3687 2550 tempMsgString.listpos = x;
3688
3689
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3690 {
3691 return qe_invalid;
3692 }
3693
3694 2550 buf[74] = '\0';
3695
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3696
3697
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3698 {
3699 return qe_invalid;
3700 }
3701
3702
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3703
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3704 {
3705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3706
3707
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3708 {
3709 return qe_invalid;
3710 }
3711
3712
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3713 {
3714 return qe_invalid;
3715 }
3716 2304 }
3717 else
3718 {
3719
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3720 {
3721 return qe_invalid;
3722 }
3723
3724
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3725 {
3726 return qe_invalid;
3727 }
3728 }
3729
3730
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3731 {
3732
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3733 2549 }
3734 2550 }
3735 24 }
3736 else
3737 {
3738 int32_t dummy_int;
3739 word s_version;
3740
3741 //section version info
3742
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
3743 {
3744 return qe_invalid;
3745 }
3746
3747
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (s_version > V_STRINGS)
3748 return qe_version;
3749
3750 457 FFCore.quest_format[vStrings] = s_version;
3751
3752
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
3753 {
3754 return qe_invalid;
3755 }
3756
3757 //section size
3758
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy_int,f))
3759 {
3760 return qe_invalid;
3761 }
3762
3763 //finally... section data
3764
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&temp_msg_count,f))
3765 {
3766 return qe_invalid;
3767 }
3768
3769
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
457 if(temp_msg_count >= msg_strings_size && !should_skip)
3770 {
3771 Z_message("Reallocating string buffer...\n");
3772
3773 delete[] MsgStrings;
3774 MsgStrings = new MsgStr[MAXMSGS];
3775 msg_strings_size = MAXMSGS;
3776 for(auto q = 0; q < msg_strings_size; ++q)
3777 {
3778 MsgStrings[q].clear();
3779 }
3780 }
3781
3782 //reset the message strings
3783
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 198 times.
457 if(s_version < 7)
3784
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3785
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (!should_skip)
3786
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 init_msgstrings(0,msg_strings_size);
3787
3788 457 int32_t string_length=(s_version<2)?73:145;
3789
3790
2/2
✓ Branch 0 taken 137794 times.
✓ Branch 1 taken 457 times.
138251 for(int32_t i=0; i<temp_msg_count; i++)
3791 {
3792
1/2
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
137794 init_msgstr(&tempMsgString);
3793 137794 tempMsgString.listpos = i;
3794
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 131926 times.
137794 if(s_version > 8)
3795 {
3796
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_igetl(&string_length,f))
3797 {
3798 return qe_invalid;
3799 }
3800 5868 }
3801
3802
2/4
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 137794 times.
137794 if (string_length < 0 || string_length > 8193)
3803 {
3804 return qe_invalid;
3805 }
3806
3807
2/2
✓ Branch 0 taken 137242 times.
✓ Branch 1 taken 552 times.
137794 if (string_length > 0)
3808 {
3809
2/4
✓ Branch 0 taken 137242 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137242 times.
✗ Branch 3 not taken.
137242 if (!pfread(buf, string_length, f))
3810 {
3811 return qe_invalid;
3812 }
3813 137242 }
3814 else
3815 {
3816 552 buf[0] = 0;
3817 }
3818
3819
2/4
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137794 times.
✗ Branch 3 not taken.
137794 if(!p_igetw(&tempMsgString.nextstring,f))
3820 {
3821 return qe_invalid;
3822 }
3823
3824
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 104181 times.
137794 if(s_version<2)
3825 {
3826 33613 buf[72] = '\0';
3827
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3828 33613 }
3829 else
3830 {
3831 // June 2008: A bug corrupted the last 4 chars of a string.
3832 // Discard these.
3833
1/2
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
104181 if(s_version<3)
3834 {
3835 for(int32_t j=140; j<144; j++)
3836 {
3837 buf[j] = '\0';
3838 }
3839 }
3840
1/2
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
104181 if(string_length > 8192) string_length = 8192;
3841 104181 buf[string_length]='\0'; //Force-terminate
3842
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104181 times.
104181 tempMsgString.setFromLegacyEncoding(buf);
3843
3844
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 98313 times.
104181 if ( s_version >= 6 )
3845 {
3846
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_igetl(&tempMsgString.tile,f))
3847 {
3848 return qe_invalid;
3849 }
3850 5868 }
3851 else
3852 {
3853
2/4
✓ Branch 0 taken 98313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98313 times.
✗ Branch 3 not taken.
98313 if(!p_igetw(&tempMsgString.tile,f))
3854 {
3855 return qe_invalid;
3856 }
3857 }
3858
3859
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.cset,f))
3860 {
3861 return qe_invalid;
3862 }
3863
3864 byte dummy_char;
3865
3866
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3867 {
3868 return qe_invalid;
3869 }
3870
3871 104181 tempMsgString.trans=dummy_char!=0;
3872
3873
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.font,f))
3874 {
3875 return qe_invalid;
3876 }
3877
3878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104181 times.
104181 if(s_version < 5)
3879 {
3880 if(!p_getc(&tempMsgString.y,f))
3881 {
3882 return qe_invalid;
3883 }
3884 }
3885 else
3886 {
3887
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.x,f))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.y,f))
3893 {
3894 return qe_invalid;
3895 }
3896
3897
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.w,f))
3898 {
3899 return qe_invalid;
3900 }
3901
3902
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.h,f))
3903 {
3904 return qe_invalid;
3905 }
3906
3907
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.hspace,f))
3908 {
3909 return qe_invalid;
3910 }
3911
3912
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.vspace,f))
3913 {
3914 return qe_invalid;
3915 }
3916
3917
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.stringflags,f))
3918 {
3919 return qe_invalid;
3920 }
3921 }
3922
3923
2/2
✓ Branch 0 taken 98313 times.
✓ Branch 1 taken 5868 times.
104181 if(s_version >= 7)
3924 {
3925
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 23472 times.
29340 for(int32_t q = 0; q < 4; ++q)
3926 {
3927
2/4
✓ Branch 0 taken 23472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23472 times.
✗ Branch 3 not taken.
23472 if(!p_getc(&tempMsgString.margins[q],f))
3928 {
3929 return qe_invalid;
3930 }
3931 23472 }
3932
3933
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_igetl(&tempMsgString.portrait_tile,f))
3934 {
3935 return qe_invalid;
3936 }
3937
3938
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_cset,f))
3939 {
3940 return qe_invalid;
3941 }
3942
3943
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_x,f))
3944 {
3945 return qe_invalid;
3946 }
3947
3948
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_y,f))
3949 {
3950 return qe_invalid;
3951 }
3952
3953
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_tw,f))
3954 {
3955 return qe_invalid;
3956 }
3957
3958
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.portrait_th,f))
3959 {
3960 return qe_invalid;
3961 }
3962 5868 }
3963
3964
2/2
✓ Branch 0 taken 5868 times.
✓ Branch 1 taken 98313 times.
104181 if(s_version >= 8)
3965 {
3966
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.shadow_type,f))
3967 {
3968 return qe_invalid;
3969 }
3970
3971
2/4
✓ Branch 0 taken 5868 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5868 times.
✗ Branch 3 not taken.
5868 if(!p_getc(&tempMsgString.shadow_color,f))
3972 {
3973 return qe_invalid;
3974 }
3975 5868 }
3976
3977
2/2
✓ Branch 0 taken 5559 times.
✓ Branch 1 taken 98622 times.
104181 if(s_version >= 10)
3978 {
3979
2/4
✓ Branch 0 taken 5559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5559 times.
✗ Branch 3 not taken.
5559 if(!p_getc(&tempMsgString.drawlayer,f))
3980 {
3981 return qe_invalid;
3982 }
3983 5559 }
3984
3985
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_getc(&tempMsgString.sfx,f))
3986 {
3987 return qe_invalid;
3988 }
3989
3990
1/2
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
104181 if(s_version>3)
3991 {
3992
2/4
✓ Branch 0 taken 104181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104181 times.
✗ Branch 3 not taken.
104181 if(!p_igetw(&tempMsgString.listpos,f))
3993 {
3994 return qe_invalid;
3995 }
3996 104181 }
3997 }
3998
3999
1/2
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
137794 if (!should_skip)
4000 {
4001
1/2
✓ Branch 0 taken 137794 times.
✗ Branch 1 not taken.
137794 MsgStrings[i].copyAll(tempMsgString);
4002 137794 }
4003 137794 }
4004 }
4005
4006
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
4007 480 msg_count=temp_msg_count;
4008
4009 481 return 0;
4010 481 }
4011
4012 481 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4013 {
4014
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4015
4016
3/4
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
487 if((Header->zelda_version < 0x192)||
4017
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 457 times.
463 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4018 {
4019 18 return 0;
4020 }
4021
4022 463 word temp_door_combo_set_count=0;
4023 DoorComboSet tempDoorComboSet;
4024 word dummy_word;
4025 int32_t dummy_long;
4026 byte padding;
4027 463 int32_t s_version = 0;
4028
4029
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 462 times.
463 if (!should_skip)
4030 {
4031 462 DoorComboSets = {};
4032 462 DoorComboSetNames = {};
4033 462 }
4034
4035
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 457 times.
463 if(Header->zelda_version > 0x192)
4036 {
4037 //section version info
4038
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
4039 {
4040 return qe_invalid;
4041 }
4042
4043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (s_version > V_DOORS)
4044 return qe_version;
4045
4046 457 FFCore.quest_format[vDoors] = s_version;
4047
4048
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy_word,f))
4049 {
4050 return qe_invalid;
4051 }
4052
4053 //section size
4054
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy_long,f))
4055 {
4056 return qe_invalid;
4057 }
4058 457 }
4059
4060 //finally... section data
4061
1/2
✓ Branch 0 taken 463 times.
✗ Branch 1 not taken.
463 if(!p_igetw(&temp_door_combo_set_count,f))
4062 {
4063 return qe_invalid;
4064 }
4065
4066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 463 times.
463 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4067 {
4068 return qe_invalid;
4069 }
4070
4071
2/2
✓ Branch 0 taken 5369 times.
✓ Branch 1 taken 463 times.
5832 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4072 {
4073 5369 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4074
4075 //name
4076 char name[21];
4077
1/2
✓ Branch 0 taken 5369 times.
✗ Branch 1 not taken.
5369 if(!pfread(&name,sizeof(name),f))
4078 {
4079 return qe_invalid;
4080 }
4081
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5355 times.
5369 if (!should_skip)
4082 5355 DoorComboSetNames[i] = name;
4083
4084
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4085 {
4086
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4087 {
4088 return qe_invalid;
4089 }
4090 40 }
4091
4092 //up door
4093
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4094 {
4095
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4096 {
4097
1/2
✓ Branch 0 taken 193284 times.
✗ Branch 1 not taken.
193284 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4098 {
4099 return qe_invalid;
4100 }
4101 193284 }
4102 48321 }
4103
4104
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4105 {
4106
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4107 {
4108
1/2
✓ Branch 0 taken 193284 times.
✗ Branch 1 not taken.
193284 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4109 {
4110 return qe_invalid;
4111 }
4112 193284 }
4113 48321 }
4114
4115 //down door
4116
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4117 {
4118
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4119 {
4120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193284 times.
193284 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4121 {
4122 return qe_invalid;
4123 }
4124 193284 }
4125 48321 }
4126
4127
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4128 {
4129
2/2
✓ Branch 0 taken 193284 times.
✓ Branch 1 taken 48321 times.
241605 for(int32_t k=0; k<4; k++)
4130 {
4131
1/2
✓ Branch 0 taken 193284 times.
✗ Branch 1 not taken.
193284 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4132 {
4133 return qe_invalid;
4134 }
4135 193284 }
4136 48321 }
4137
4138 //left door
4139
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4140 {
4141
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4142 {
4143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289926 times.
289926 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4144 {
4145 return qe_invalid;
4146 }
4147 289926 }
4148 48321 }
4149
4150
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4151 {
4152
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4153 {
4154
1/2
✓ Branch 0 taken 289926 times.
✗ Branch 1 not taken.
289926 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4155 {
4156 return qe_invalid;
4157 }
4158 289926 }
4159 48321 }
4160
4161 //right door
4162
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4163 {
4164
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4165 {
4166
1/2
✓ Branch 0 taken 289926 times.
✗ Branch 1 not taken.
289926 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4167 {
4168 return qe_invalid;
4169 }
4170 289926 }
4171 48321 }
4172
4173
2/2
✓ Branch 0 taken 48321 times.
✓ Branch 1 taken 5369 times.
53690 for(int32_t j=0; j<9; j++)
4174 {
4175
2/2
✓ Branch 0 taken 289926 times.
✓ Branch 1 taken 48321 times.
338247 for(int32_t k=0; k<6; k++)
4176 {
4177
1/2
✓ Branch 0 taken 289926 times.
✗ Branch 1 not taken.
289926 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4178 {
4179 return qe_invalid;
4180 }
4181 289926 }
4182 48321 }
4183
4184 //up bomb rubble
4185
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4186 {
4187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4188 {
4189 return qe_invalid;
4190 }
4191 10738 }
4192
4193
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4194 {
4195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4196 {
4197 return qe_invalid;
4198 }
4199 10738 }
4200
4201 //down bomb rubble
4202
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4203 {
4204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4205 {
4206 return qe_invalid;
4207 }
4208 10738 }
4209
4210
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4211 {
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4213 {
4214 return qe_invalid;
4215 }
4216 10738 }
4217
4218 //left bomb rubble
4219
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4220 {
4221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4222 {
4223 return qe_invalid;
4224 }
4225 16107 }
4226
4227
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4228 {
4229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4230 {
4231 return qe_invalid;
4232 }
4233 16107 }
4234
4235
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4236 {
4237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4238 {
4239 return qe_invalid;
4240 }
4241
4242 40 }
4243
4244 //right bomb rubble
4245
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4246 {
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4248 {
4249 return qe_invalid;
4250 }
4251 16107 }
4252
4253
2/2
✓ Branch 0 taken 16107 times.
✓ Branch 1 taken 5369 times.
21476 for(int32_t j=0; j<3; j++)
4254 {
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16107 times.
16107 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4256 {
4257 return qe_invalid;
4258 }
4259 16107 }
4260
4261
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4262 {
4263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4264 {
4265 return qe_invalid;
4266 }
4267 40 }
4268
4269 //walkthrough stuff
4270
2/2
✓ Branch 0 taken 21476 times.
✓ Branch 1 taken 5369 times.
26845 for(int32_t j=0; j<4; j++)
4271 {
4272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21476 times.
21476 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4273 {
4274 return qe_invalid;
4275 }
4276 21476 }
4277
4278
2/2
✓ Branch 0 taken 21476 times.
✓ Branch 1 taken 5369 times.
26845 for(int32_t j=0; j<4; j++)
4279 {
4280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21476 times.
21476 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4281 {
4282 return qe_invalid;
4283 }
4284 21476 }
4285
4286 //flags
4287
2/2
✓ Branch 0 taken 10738 times.
✓ Branch 1 taken 5369 times.
16107 for(int32_t j=0; j<2; j++)
4288 {
4289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10738 times.
10738 if(!p_getc(&tempDoorComboSet.flags[j],f))
4290 {
4291 return qe_invalid;
4292 }
4293 10738 }
4294
4295
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 40 times.
5369 if(Header->zelda_version < 0x193)
4296 {
4297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4298 {
4299 return qe_invalid;
4300 }
4301 40 }
4302
4303
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5355 times.
5369 if (!should_skip)
4304 5355 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4305 5369 }
4306
4307
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 462 times.
463 if (!should_skip)
4308 462 door_combo_set_count=temp_door_combo_set_count;
4309
4310 463 return 0;
4311 481 }
4312
4313 9 int32_t count_dmaps()
4314 {
4315 9 int32_t i=MAXDMAPS-1;
4316 9 bool found=false;
4317
4318
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4319 {
4320
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4321
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4322
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4323 18 found=true;
4324
4325
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4326 {
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4328
4329 found=true;
4330 72 }
4331
4332
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4333 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4334 27 found=true;
4335
4336
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4337
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4338
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4339
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4340 18 found=true;
4341
4342 if(!found)
4343 {
4344 i--;
4345 }
4346 }
4347
4348 9 return i+1;
4349 }
4350
4351
4352 9 int32_t count_shops(miscQdata *Misc)
4353 {
4354 9 int32_t i=NUM_SHOPS-1,j;
4355 9 bool found=false;
4356
4357
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4358 {
4359 2229 j=2;
4360
4361
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4362 {
4363
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4364 {
4365 5 found=true;
4366 5 }
4367 else
4368 {
4369 6672 j--;
4370 }
4371 }
4372
4373
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4374 {
4375 found=true;
4376 }
4377
4378
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4379 {
4380 2224 i--;
4381 2224 }
4382 }
4383
4384 9 return i+1;
4385 }
4386
4387 9 int32_t count_infos(miscQdata *Misc)
4388 {
4389 9 int32_t i=255,j;
4390 9 bool found=false;
4391
4392
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4393 {
4394 2229 j=2;
4395
4396
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4397 {
4398
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4399 {
4400 5 found=true;
4401 5 }
4402 else
4403 {
4404 6672 j--;
4405 }
4406 }
4407
4408
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4409 {
4410 found=true;
4411 }
4412
4413
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4414 {
4415 2224 i--;
4416 2224 }
4417 }
4418
4419 9 return i+1;
4420 }
4421
4422 9 int32_t count_warprings(miscQdata *Misc)
4423 {
4424 9 int32_t i=15,j;
4425 9 bool found=false;
4426
4427
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4428 {
4429 49 j=7;
4430
4431
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4432 {
4433
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4434 {
4435 9 found=true;
4436 9 }
4437 else
4438 {
4439 349 j--;
4440 }
4441 }
4442
4443
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4444 {
4445 40 i--;
4446 40 }
4447 }
4448
4449 9 return i+1;
4450 }
4451
4452 9 int32_t count_palcycles(miscQdata *Misc)
4453 {
4454 9 int32_t i=255,j;
4455 9 bool found=false;
4456
4457
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4458 {
4459 2036 j=2;
4460
4461
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4462 {
4463
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4464 {
4465 7 found=true;
4466 7 }
4467 else
4468 {
4469 6087 j--;
4470 }
4471 }
4472
4473
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4474 {
4475 2029 i--;
4476 2029 }
4477 }
4478
4479 9 return i+1;
4480 }
4481
4482 18088 void clear_screen(mapscr *temp_scr)
4483 {
4484 18088 temp_scr->zero_memory();
4485 18088 }
4486
4487 // NOTE: when modifying this, you need to also update:
4488 // readonedmap, readdmaps, and FFScript::read_dmaps
4489 // (and their associated write functions)
4490 3553 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4491 {
4492
2/2
✓ Branch 0 taken 3529 times.
✓ Branch 1 taken 24 times.
3553 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4493
4494 3553 word dmapstoread=0;
4495 3553 dmap tempDMap;
4496
4497 int32_t dummy;
4498 3553 word s_version=0;
4499 byte padding;
4500
4501 char legacy_title[22];
4502
4503
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 480 times.
3553 if (!should_skip)
4504
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<max_dmaps; i++)
4505 {
4506
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 DMaps[start_dmap + i].clear();
4507 245760 sprintf(legacy_title," ");
4508 245760 sprintf(DMaps[start_dmap+i].intro," ");
4509 245760 DMaps[start_dmap+i].type |= dmCAVE;
4510 246240 }
4511
4512
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
3553 if (!should_skip && s_version == 21)
4513 Regions = {};
4514
4515 3553 Header->is_z3 = false;
4516
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 457 times.
✓ Branch 3 taken 24 times.
3553 if(!Header || Header->zelda_version > 0x192)
4517 {
4518 //section version info
4519
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
3529 if(!p_igetw(&s_version,f))
4520 {
4521 return qe_invalid;
4522 }
4523
4524
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (s_version > V_DMAPS)
4525 return qe_version;
4526
4527 457 Header->is_z3 = s_version >= 22;
4528 457 FFCore.quest_format[vDMaps] = s_version;
4529
4530
4531
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
4532 {
4533 return qe_invalid;
4534 }
4535
4536 //section size
4537
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
4538 {
4539 return qe_invalid;
4540 }
4541
4542 //finally... section data
4543
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dmapstoread,f))
4544 {
4545 return qe_invalid;
4546 }
4547 457 }
4548 else
4549 {
4550
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4551
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4552 {
4553 18 dmapstoread=32;
4554 18 }
4555
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4556 {
4557 6 dmapstoread=OLDMAXDMAPS;
4558 6 }
4559 else
4560 {
4561 dmapstoread=MAXDMAPS;
4562 }
4563 }
4564
4565
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 398 times.
481 dmapstoread=zc_min(dmapstoread, max_dmaps);
4566
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 398 times.
481 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4567
4568
2/2
✓ Branch 0 taken 220992 times.
✓ Branch 1 taken 481 times.
221473 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4569 {
4570
1/2
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
220992 tempDMap.clear();
4571 220992 sprintf(legacy_title," ");
4572 220992 sprintf(tempDMap.intro," ");
4573
4574
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.map,f))
4575 {
4576 return qe_invalid;
4577 }
4578
4579
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 203776 times.
220992 if(s_version <= 4)
4580 {
4581 byte tempbyte;
4582
4583
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4584 {
4585 return qe_invalid;
4586 }
4587
4588 17216 tempDMap.level=(word)tempbyte;
4589 17216 }
4590 else
4591 {
4592
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetw(&tempDMap.level,f))
4593 {
4594 return qe_invalid;
4595 }
4596 }
4597
4598
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.xoff,f))
4599 {
4600 return qe_invalid;
4601 }
4602
4603
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.compass,f))
4604 {
4605 return qe_invalid;
4606 }
4607
4608
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version > 8) // February 2009
4609 {
4610
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetw(&tempDMap.color,f))
4611 {
4612 return qe_invalid;
4613 }
4614 203776 }
4615 else
4616 {
4617 byte tempbyte;
4618
4619
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4620 {
4621 return qe_invalid;
4622 }
4623
4624 17216 tempDMap.color = (word)tempbyte;
4625 }
4626
4627
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.midi,f))
4628 {
4629 return qe_invalid;
4630 }
4631
4632
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.cont,f))
4633 {
4634 return qe_invalid;
4635 }
4636
4637
2/4
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220992 times.
✗ Branch 3 not taken.
220992 if(!p_getc(&tempDMap.type,f))
4638 {
4639 return qe_invalid;
4640 }
4641
4642
4/4
✓ Branch 0 taken 5931 times.
✓ Branch 1 taken 215061 times.
✓ Branch 2 taken 5887 times.
✓ Branch 3 taken 44 times.
226923 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4643
1/2
✓ Branch 0 taken 5931 times.
✗ Branch 1 not taken.
5931 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4644 5887 tempDMap.xoff = 0;
4645
4646
2/2
✓ Branch 0 taken 220992 times.
✓ Branch 1 taken 1767936 times.
1988928 for(int32_t j=0; j<8; j++)
4647 {
4648
2/4
✓ Branch 0 taken 1767936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1767936 times.
✗ Branch 3 not taken.
1767936 if(!p_getc(&tempDMap.grid[j],f))
4649 {
4650 return qe_invalid;
4651 }
4652 1767936 }
4653
4654
5/6
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 218880 times.
220992 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4655 {
4656
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4657 {
4658 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4659 127 }
4660
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4661
4662
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4663 {
4664
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4665
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4666 18 }
4667
4668 //forgotten -DD
4669
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4670 {
4671 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4672 439 }
4673 576 }
4674 else
4675 {
4676
3/4
✓ Branch 0 taken 220416 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
218880 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4677 {
4678 return qe_invalid;
4679 }
4680
4681
2/2
✓ Branch 0 taken 127744 times.
✓ Branch 1 taken 92672 times.
220416 if(s_version<20)
4682 {
4683
2/4
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127744 times.
✗ Branch 3 not taken.
127744 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4684 {
4685 return qe_invalid;
4686 }
4687
1/2
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
127744 tempDMap.title.assign(legacy_title);
4688 127744 }
4689 else
4690 {
4691
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_getwstr(&tempDMap.title, f))
4692 {
4693 return qe_invalid;
4694 }
4695 }
4696
4697
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4698 {
4699 return qe_invalid;
4700 }
4701
4702
5/8
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 218880 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
220416 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4703 {
4704 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4705 DMaps[i] = tempDMap;
4706
4707 continue;
4708 }
4709
4710
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4711 {
4712
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4713 {
4714 return qe_invalid;
4715 }
4716 1536 }
4717
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4718 {
4719
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4720 {
4721 return qe_invalid;
4722 }
4723 101376 }
4724 else
4725 {
4726
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4727 {
4728 return qe_invalid;
4729 }
4730 }
4731
4732
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.minimap_cset[0],f))
4733 {
4734 return qe_invalid;
4735 }
4736
4737
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4738 {
4739
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4740 {
4741 return qe_invalid;
4742 }
4743 1536 }
4744
4745
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4746 {
4747
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4748 {
4749 return qe_invalid;
4750 }
4751 101376 }
4752 else
4753 {
4754
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4755 {
4756 return qe_invalid;
4757 }
4758 }
4759
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.minimap_cset[1],f))
4760 {
4761 return qe_invalid;
4762 }
4763
4764
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4765 {
4766
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4767 {
4768 return qe_invalid;
4769 }
4770 1536 }
4771
4772
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4773 {
4774
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4775 {
4776 return qe_invalid;
4777 }
4778 101376 }
4779 else
4780 {
4781
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4782 {
4783 return qe_invalid;
4784 }
4785 }
4786
4787
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.largemap_cset[0],f))
4788 {
4789 return qe_invalid;
4790 }
4791
4792
3/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 218880 times.
220416 if(Header && (Header->zelda_version < 0x193))
4793 {
4794
4795
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4796 {
4797 return qe_invalid;
4798 }
4799 1536 }
4800
4801
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119040 times.
220416 if ( s_version >= 11 )
4802 {
4803
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4804 {
4805 return qe_invalid;
4806 }
4807 101376 }
4808 else
4809 {
4810
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4811 {
4812 return qe_invalid;
4813 }
4814 }
4815
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getc(&tempDMap.largemap_cset[1],f))
4816 {
4817 return qe_invalid;
4818 }
4819
4820
2/4
✓ Branch 0 taken 220416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220416 times.
✗ Branch 3 not taken.
220416 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4821 {
4822 return qe_invalid;
4823 }
4824 }
4825
4826
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version>1)
4827 {
4828
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.tmusictrack,f))
4829 {
4830 return qe_invalid;
4831 }
4832
4833
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.active_subscreen,f))
4834 {
4835 return qe_invalid;
4836 }
4837
4838
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_getc(&tempDMap.passive_subscreen,f))
4839 {
4840 return qe_invalid;
4841 }
4842 203776 }
4843
4844
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version>2)
4845 {
4846 byte di[32];
4847
4848
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!pfread(&di, 32, f)) return qe_invalid;
4849
4850
2/2
✓ Branch 0 taken 52166656 times.
✓ Branch 1 taken 203776 times.
52370432 for(int32_t j=0; j<MAXITEMS; j++)
4851 {
4852
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 52157449 times.
52166656 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4853 52157449 else tempDMap.disableditems[j]=0;
4854 52166656 }
4855 203776 }
4856
4857
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version >= 6)
4858 {
4859
2/4
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203776 times.
✗ Branch 3 not taken.
203776 if(!p_igetl(&tempDMap.flags,f))
4860 {
4861 return qe_invalid;
4862 }
4863 203776 }
4864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4865 {
4866 char temp;
4867
4868 if(!p_getc(&temp,f))
4869 {
4870 return qe_invalid;
4871 }
4872
4873 tempDMap.flags = temp;
4874 }
4875
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4876 {
4877 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4878 8992 }
4879 else
4880 8224 tempDMap.flags=0;
4881
4882
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version<7)
4883 {
4884
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6146 times.
✓ Branch 5 taken 2846 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4885 6146 tempDMap.flags|= dmfVIEWMAP;
4886 17216 }
4887
4888
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 17216 times.
220992 if(s_version<8)
4889 {
4890
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4891 {
4892
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4893 8050 tempDMap.type |= dmCAVE;
4894 8050 }
4895
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4896 {
4897 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4898 2332 }
4899 17216 }
4900
4901
7/8
✓ Branch 0 taken 220992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 218880 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 218880 times.
220992 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4902 220416 && (Header->zelda_version < 0x193))
4903 {
4904
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4905 {
4906 return qe_invalid;
4907 }
4908 1536 }
4909
4910
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 101376 times.
220992 if(s_version >= 10)
4911 {
4912
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_getc(&tempDMap.sideview,f))
4913 {
4914 return qe_invalid;
4915 }
4916 101376 }
4917
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version < 10) tempDMap.sideview = 0;
4918
4919 //Dmap Scripts
4920
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 12)
4921 {
4922
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.script,f))
4923 {
4924 return qe_invalid;
4925 }
4926
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
4927 {
4928
2/4
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811008 times.
✗ Branch 3 not taken.
811008 if(!p_igetl(&tempDMap.initD[q],f))
4929 {
4930 return qe_invalid;
4931 }
4932 811008 }
4933 101376 }
4934
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if ( s_version < 12 )
4935 {
4936 119616 tempDMap.script = 0;
4937
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4938 {
4939 956928 tempDMap.initD[q] = 0;
4940 956928 }
4941 119616 }
4942
4943
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 101376 times.
220992 if(s_version >= 13)
4944 {
4945
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
4946 {
4947
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; w++ )
4948 {
4949
2/4
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52715520 times.
✗ Branch 3 not taken.
52715520 if(!p_getc(&tempDMap.initD_label[q][w],f))
4950 {
4951 return qe_invalid;
4952 }
4953 52715520 }
4954 811008 }
4955 101376 }
4956
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if ( s_version < 13 )
4957 {
4958 119616 tempDMap.script = 0;
4959
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4960 {
4961
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for ( int32_t w = 0; w < 65; w++ )
4962 62200320 tempDMap.initD_label[q][w] = 0;
4963 956928 }
4964 119616 }
4965
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 14)
4966 {
4967
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.active_sub_script,f))
4968 {
4969 return qe_invalid;
4970 }
4971
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.passive_sub_script,f))
4972 {
4973 return qe_invalid;
4974 }
4975
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; ++q )
4976 {
4977
2/4
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811008 times.
✗ Branch 3 not taken.
811008 if(!p_igetl(&tempDMap.sub_initD[q],f))
4978 {
4979 return qe_invalid;
4980 }
4981 811008 }
4982
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for(int32_t q = 0; q < 8; ++q)
4983 {
4984
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; ++w )
4985 {
4986
2/4
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52715520 times.
✗ Branch 3 not taken.
52715520 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4987 {
4988 return qe_invalid;
4989 }
4990 52715520 }
4991 811008 }
4992 101376 }
4993 else
4994 {
4995 119616 tempDMap.active_sub_script = 0;
4996 119616 tempDMap.passive_sub_script = 0;
4997
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
4998 {
4999 956928 tempDMap.sub_initD[q] = 0;
5000
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5001 62200320 tempDMap.sub_initD_label[q][w] = 0;
5002 956928 }
5003 }
5004
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 15)
5005 {
5006
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.onmap_script,f))
5007 {
5008 return qe_invalid;
5009 }
5010
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; ++q )
5011 {
5012
2/4
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811008 times.
✗ Branch 3 not taken.
811008 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5013 {
5014 return qe_invalid;
5015 }
5016 811008 }
5017
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for(int32_t q = 0; q < 8; ++q)
5018 {
5019
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; ++w )
5020 {
5021
2/4
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52715520 times.
✗ Branch 3 not taken.
52715520 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5022 {
5023 return qe_invalid;
5024 }
5025 52715520 }
5026 811008 }
5027 101376 }
5028 else
5029 {
5030 119616 tempDMap.onmap_script = 0;
5031
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
5032 {
5033 956928 tempDMap.onmap_initD[q] = 0;
5034
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5035 {
5036 62200320 tempDMap.onmap_initD_label[q][w] = 0;
5037 62200320 }
5038 956928 }
5039 }
5040
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 119616 times.
220992 if(s_version >= 16)
5041 {
5042
2/4
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
101376 if(!p_igetw(&tempDMap.mirrorDMap,f))
5043 {
5044 return qe_invalid;
5045 }
5046 101376 }
5047 else
5048 {
5049 119616 tempDMap.mirrorDMap = -1;
5050 }
5051
5052 // Enhanced music loop points
5053
2/2
✓ Branch 0 taken 92672 times.
✓ Branch 1 taken 128320 times.
220992 if (s_version >= 18)
5054 {
5055
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5056 {
5057 return qe_invalid;
5058 }
5059
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5060 {
5061 return qe_invalid;
5062 }
5063
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5064 {
5065 return qe_invalid;
5066 }
5067
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5068 {
5069 return qe_invalid;
5070 }
5071 92672 }
5072 else
5073 {
5074 128320 tempDMap.tmusic_loop_start = 0;
5075 128320 tempDMap.tmusic_loop_end = 0;
5076 128320 tempDMap.tmusic_xfade_in = 0;
5077 128320 tempDMap.tmusic_xfade_out = 0;
5078 }
5079
5080
2/2
✓ Branch 0 taken 92672 times.
✓ Branch 1 taken 128320 times.
220992 if(s_version >= 19)
5081
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if(!p_getc(&tempDMap.overlay_subscreen, f))
5082 return qe_invalid;
5083
5084
2/2
✓ Branch 0 taken 92672 times.
✓ Branch 1 taken 128320 times.
220992 if (s_version >= 20)
5085 {
5086
2/4
✓ Branch 0 taken 92672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92672 times.
✗ Branch 3 not taken.
92672 if (!p_igetl(&tempDMap.intro_string_id, f))
5087 return qe_invalid;
5088 92672 }
5089 else
5090 128320 tempDMap.intro_string_id = 0;
5091
5092
2/2
✓ Branch 0 taken 206656 times.
✓ Branch 1 taken 14336 times.
220992 if(s_version == 21)
5093 {
5094 static regions_data tmp_rd;
5095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5096
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5097 {
5098
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5099 {
5100
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5101 {
5102 return qe_invalid;
5103 }
5104 917504 }
5105 114688 }
5106 14336 }
5107
5108
3/4
✓ Branch 0 taken 65536 times.
✓ Branch 1 taken 155456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65536 times.
220992 if (s_version > 22 && (tempDMap.flags & dmfCUSTOM_GRAVITY))
5109 {
5110 if (!p_igetzf(&tempDMap.dmap_gravity, f))
5111 return qe_invalid;
5112 if (!p_igetzf(&tempDMap.dmap_terminal_v, f))
5113 return qe_invalid;
5114 }
5115
5116
2/2
✓ Branch 0 taken 220736 times.
✓ Branch 1 taken 256 times.
220992 if (!should_skip)
5117 {
5118
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 if(loading_tileset_flags & TILESET_CLEARMAPS)
5119 tempDMap.map = 0;
5120
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5121 {
5122 tempDMap.script = 0;
5123 for(int q = 0; q < 8; ++q)
5124 tempDMap.initD[q] = 0;
5125 }
5126
1/2
✓ Branch 0 taken 220736 times.
✗ Branch 1 not taken.
220736 DMaps[i] = tempDMap;
5127 220736 }
5128 220992 }
5129
5130 481 return 0;
5131 6625 }
5132
5133 398 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5134 {
5135 //these are here to bypass compiler warnings about unused arguments
5136 398 Header=Header;
5137
5138 miscQdata temp_misc;
5139 398 word s_version=0;
5140 398 int32_t tempsize=0;
5141 word dummyw;
5142
5143 398 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5144
5145 //section version info
5146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
5147 {
5148 return qe_invalid;
5149 }
5150
5151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_COLORS)
5152 return qe_version;
5153
5154 398 FFCore.quest_format[vColours] = s_version;
5155
5156 398 al_trace("Misc Colours section version: %d\n", s_version);
5157
5158
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
5159 {
5160 return qe_invalid;
5161 }
5162
5163
5164 //section size
5165
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&tempsize,f))
5166 {
5167 return qe_invalid;
5168 }
5169
5170 //finally... section data
5171 398 readsize=0;
5172
5173
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.text,f))
5174 {
5175 return qe_invalid;
5176 }
5177
5178
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.caption,f))
5179 {
5180 return qe_invalid;
5181 }
5182
5183
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.overw_bg,f))
5184 {
5185 return qe_invalid;
5186 }
5187
5188
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5189 {
5190 return qe_invalid;
5191 }
5192
5193
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5194 {
5195 return qe_invalid;
5196 }
5197
5198
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.cave_fg,f))
5199 {
5200 return qe_invalid;
5201 }
5202
5203
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bs_dk,f))
5204 {
5205 return qe_invalid;
5206 }
5207
5208
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bs_goal,f))
5209 {
5210 return qe_invalid;
5211 }
5212
5213
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.compass_lt,f))
5214 {
5215 return qe_invalid;
5216 }
5217
5218
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.compass_dk,f))
5219 {
5220 return qe_invalid;
5221 }
5222
5223
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5224 {
5225 return qe_invalid;
5226 }
5227
5228
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triframe_color,f))
5229 {
5230 return qe_invalid;
5231 }
5232
5233
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.hero_dot,f))
5234 {
5235 return qe_invalid;
5236 }
5237
5238
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5239 {
5240 return qe_invalid;
5241 }
5242
5243
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5244 {
5245 return qe_invalid;
5246 }
5247
5248
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5249 {
5250 return qe_invalid;
5251 }
5252
5253
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5259 {
5260 return qe_invalid;
5261 }
5262
5263
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5264 {
5265 return qe_invalid;
5266 }
5267
5268
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5269 {
5270 return qe_invalid;
5271 }
5272
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version < 4)
5273 {
5274
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5275 return qe_invalid;
5276 200 temp_misc.colors.triforce_tile = dummyw;
5277
5278
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5279 return qe_invalid;
5280 200 temp_misc.colors.triframe_tile = dummyw;
5281
5282
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5283 return qe_invalid;
5284 200 temp_misc.colors.overworld_map_tile = dummyw;
5285
5286
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5287 return qe_invalid;
5288 200 temp_misc.colors.dungeon_map_tile = dummyw;
5289
5290
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5291 return qe_invalid;
5292 200 temp_misc.colors.blueframe_tile = dummyw;
5293
5294
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5295 return qe_invalid;
5296 200 temp_misc.colors.HCpieces_tile = dummyw;
5297 200 }
5298
5299
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5300 {
5301 return qe_invalid;
5302 }
5303
5304
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5305 {
5306 return qe_invalid;
5307 }
5308
5309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version < 2)
5310 {
5311 temp_misc.colors.msgtext = 0x01;
5312 }
5313 else
5314 {
5315
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_getc(&temp_misc.colors.msgtext, f))
5316 {
5317 return qe_invalid;
5318 }
5319 }
5320
5321
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if ( s_version >= 3 ) //expanded tile pages to 825
5322 {
5323
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5324 {
5325 return qe_invalid;
5326 }
5327
5328
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5329 {
5330 return qe_invalid;
5331 }
5332
5333
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5334 {
5335 return qe_invalid;
5336 }
5337
5338
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5339 {
5340 return qe_invalid;
5341 }
5342
5343
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5349 {
5350 return qe_invalid;
5351 }
5352 198 }
5353
5354 398 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5355
5356 398 return 0;
5357 398 }
5358
5359 398 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5360 {
5361 miscQdata temp_misc;
5362 398 word s_version=0;
5363 byte icons;
5364 398 int32_t tempsize=0;
5365
5366 398 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5367
5368 //section version info
5369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
5370 {
5371 return qe_invalid;
5372 }
5373
5374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_ICONS)
5375 return qe_version;
5376
5377 398 FFCore.quest_format[vIcons] = s_version;
5378
5379
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
5380 {
5381 return qe_invalid;
5382 }
5383
5384
5385 //section size
5386
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&tempsize,f))
5387 {
5388 return qe_invalid;
5389 }
5390
5391 //finally... section data
5392 398 readsize=0;
5393
5394 398 icons=4;
5395
5396
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if ( s_version >= 10 )
5397 {
5398
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<icons; i++)
5399 {
5400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&temp_misc.icons[i],f))
5401 {
5402 return qe_invalid;
5403 }
5404 792 }
5405 198 }
5406 else
5407 {
5408
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<icons; i++)
5409 {
5410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_igetw(&temp_misc.icons[i],f))
5411 {
5412 return qe_invalid;
5413 }
5414 800 }
5415 }
5416
5417 398 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5418
5419 398 return 0;
5420 398 }
5421
5422 804 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5423 {
5424
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5425
5426 804 word maxinfos=256;
5427 804 word maxshops=256;
5428 804 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5429 804 word ponds=16, pondsize=72, expansionsize=98*2;
5430 byte tempbyte, padding;
5431 miscQdata temp_misc;
5432 804 word s_version=0;
5433 word swaptmp;
5434 804 int32_t tempsize=0;
5435
5436 804 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5437
5438
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxshops; ++i)
5439 {
5440 205824 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5441 205824 }
5442
5443
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxinfos; ++i)
5444 {
5445 205824 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5446 205824 }
5447
5448 804 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5449
5450
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5451 {
5452 //section version info
5453
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&s_version,f))
5454 {
5455 return qe_invalid;
5456 }
5457
5458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if (s_version > V_MISC)
5459 return qe_version;
5460
5461 780 FFCore.quest_format[vMisc] = s_version;
5462
5463
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!read_deprecated_section_cversion(f))
5464 {
5465 return qe_invalid;
5466 }
5467
5468
5469 //section size
5470
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&tempsize,f))
5471 {
5472 return qe_invalid;
5473 }
5474 780 }
5475
5476 //finally... section data
5477 804 readsize=0;
5478
5479 //shops
5480
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5481 {
5482
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&shops,f))
5483 {
5484 return qe_invalid;
5485 }
5486 780 }
5487
5488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (shops > NUM_SHOPS)
5489 {
5490 return qe_invalid;
5491 }
5492
5493
2/2
✓ Branch 0 taken 11102 times.
✓ Branch 1 taken 804 times.
11906 for(int32_t i=0; i<shops; i++)
5494 {
5495
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9902 times.
11102 if(s_version > 6)
5496 {
5497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9902 times.
9902 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5498 {
5499 return qe_invalid;
5500 }
5501 9902 }
5502
5503
2/2
✓ Branch 0 taken 33306 times.
✓ Branch 1 taken 11102 times.
44408 for(int32_t j=0; j<3; j++)
5504 {
5505
1/2
✓ Branch 0 taken 33306 times.
✗ Branch 1 not taken.
33306 if(!p_getc(&temp_misc.shop[i].item[j],f))
5506 {
5507 return qe_invalid;
5508 }
5509
5510
2/2
✓ Branch 0 taken 29706 times.
✓ Branch 1 taken 3600 times.
33306 if(s_version < 4)
5511 {
5512 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5513 3600 }
5514 33306 }
5515
5516
2/2
✓ Branch 0 taken 10718 times.
✓ Branch 1 taken 384 times.
11102 if(Header->zelda_version < 0x193)
5517 {
5518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5519 {
5520 return qe_invalid;
5521 }
5522 384 }
5523
5524
2/2
✓ Branch 0 taken 33306 times.
✓ Branch 1 taken 11102 times.
44408 for(int32_t j=0; j<3; j++)
5525 {
5526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33306 times.
33306 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5527 {
5528 return qe_invalid;
5529 }
5530 33306 }
5531
5532
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9902 times.
11102 if(s_version > 3)
5533 {
5534
2/2
✓ Branch 0 taken 29706 times.
✓ Branch 1 taken 9902 times.
39608 for(int32_t j=0; j<3; j++)
5535 {
5536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29706 times.
29706 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5537 return qe_invalid;
5538 29706 }
5539 9902 }
5540
5541 /*
5542 if(s_version < 8)
5543 {
5544 for(int32_t j=0; j<3; j++)
5545 {
5546 (&temp_misc.shop[i].str[j])=0; //initialise.
5547 }
5548 }
5549 */
5550 11102 }
5551
5552 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5553
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxshops; ++i)
5554 {
5555
2/2
✓ Branch 0 taken 411648 times.
✓ Branch 1 taken 205824 times.
617472 for(int32_t j=0; j<3-1; j++)
5556 {
5557
2/2
✓ Branch 0 taken 617472 times.
✓ Branch 1 taken 411648 times.
1029120 for(int32_t k=0; k<2-j; k++)
5558 {
5559
2/2
✓ Branch 0 taken 593535 times.
✓ Branch 1 taken 23937 times.
617472 if(temp_misc.shop[i].hasitem[k]==0)
5560 {
5561 593535 swaptmp = temp_misc.shop[i].item[k];
5562 593535 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5563 593535 temp_misc.shop[i].item[k+1] = swaptmp;
5564 593535 swaptmp = temp_misc.shop[i].price[k];
5565 593535 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5566 593535 temp_misc.shop[i].price[k+1] = swaptmp;
5567 593535 swaptmp = temp_misc.shop[i].hasitem[k];
5568 593535 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5569 593535 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5570 593535 }
5571 617472 }
5572 411648 }
5573 205824 }
5574
5575 //infos
5576
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5577 {
5578
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&infos,f))
5579 {
5580 return qe_invalid;
5581 }
5582 780 }
5583
5584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (infos > NUM_INFOS)
5585 {
5586 return qe_invalid;
5587 }
5588
5589
5590
2/2
✓ Branch 0 taken 10408 times.
✓ Branch 1 taken 804 times.
11212 for(int32_t i=0; i<infos; i++)
5591 {
5592
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9647 times.
10408 if(s_version > 6)
5593 {
5594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647 times.
9647 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5595 {
5596 return qe_invalid;
5597 }
5598 9647 }
5599
5600
2/2
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 10408 times.
41632 for(int32_t j=0; j<3; j++)
5601 {
5602
3/4
✓ Branch 0 taken 30360 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
31512 if((Header->zelda_version < 0x192)||
5603
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 30072 times.
30360 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5604 {
5605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5606 {
5607 return qe_invalid;
5608 }
5609
5610 864 temp_misc.info[i].str[j]=tempbyte;
5611 864 }
5612 else
5613 {
5614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30360 times.
30360 if(!p_igetw(&temp_misc.info[i].str[j],f))
5615 {
5616 return qe_invalid;
5617 }
5618 }
5619 31224 }
5620
5621
2/2
✓ Branch 0 taken 10024 times.
✓ Branch 1 taken 384 times.
10408 if(Header->zelda_version < 0x193)
5622 {
5623
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5624 {
5625 return qe_invalid;
5626 }
5627 384 }
5628
5629
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10408 if((Header->zelda_version == 0x192)&&(Header->build>145))
5630 {
5631
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5632 {
5633 return qe_invalid;
5634 }
5635 96 }
5636
5637
2/2
✓ Branch 0 taken 31224 times.
✓ Branch 1 taken 10408 times.
41632 for(int32_t j=0; j<3; j++)
5638 {
5639
1/2
✓ Branch 0 taken 31224 times.
✗ Branch 1 not taken.
31224 if(!p_igetw(&temp_misc.info[i].price[j],f))
5640 {
5641 return qe_invalid;
5642 }
5643 31224 }
5644 10408 }
5645
5646 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5647
2/2
✓ Branch 0 taken 205824 times.
✓ Branch 1 taken 804 times.
206628 for(int32_t i=0; i<maxinfos; ++i)
5648 {
5649
2/2
✓ Branch 0 taken 411648 times.
✓ Branch 1 taken 205824 times.
617472 for(int32_t j=0; j<3-1; j++)
5650 {
5651
2/2
✓ Branch 0 taken 617472 times.
✓ Branch 1 taken 411648 times.
1029120 for(int32_t k=0; k<2-j; k++)
5652 {
5653
2/2
✓ Branch 0 taken 11788 times.
✓ Branch 1 taken 605684 times.
617472 if(temp_misc.info[i].str[k]==0)
5654 {
5655 605684 swaptmp = temp_misc.info[i].str[k];
5656 605684 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5657 605684 temp_misc.info[i].str[k+1] = swaptmp;
5658 605684 swaptmp = temp_misc.info[i].price[k];
5659 605684 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5660 605684 temp_misc.info[i].price[k+1] = swaptmp;
5661 605684 }
5662 617472 }
5663 411648 }
5664 205824 }
5665
5666
5667 //warp rings
5668
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 721 times.
804 if(s_version > 5)
5669 721 warprings++;
5670
5671
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(Header->zelda_version > 0x192)
5672 {
5673
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&warprings,f))
5674 {
5675 return qe_invalid;
5676 }
5677
5678
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 440 times.
780 if (warprings > NUM_WARP_RINGS)
5679 {
5680 // return qe_invalid;
5681 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5682 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5683 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5684 440 }
5685 780 }
5686
5687
2/2
✓ Branch 0 taken 8404 times.
✓ Branch 1 taken 804 times.
9208 for(int32_t i=0; i<warprings; i++)
5688 {
5689 // See above comment on the `warprings` range check.
5690 8404 bool keepdata = i < NUM_WARP_RINGS;
5691
5692
2/2
✓ Branch 0 taken 74516 times.
✓ Branch 1 taken 8404 times.
82920 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5693 {
5694
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 65556 times.
74516 if(s_version <= 3)
5695 {
5696
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5697 {
5698 return qe_invalid;
5699 }
5700
5701
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5702 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5703 8960 }
5704 else
5705 {
5706 word tempword;
5707
1/2
✓ Branch 0 taken 65556 times.
✗ Branch 1 not taken.
65556 if(!p_igetw(&tempword,f))
5708 {
5709 return qe_invalid;
5710 }
5711
5712
2/2
✓ Branch 0 taken 7461 times.
✓ Branch 1 taken 58095 times.
65556 if (keepdata)
5713 58095 temp_misc.warp[i].dmap[j] = tempword;
5714 }
5715 74516 }
5716
5717
2/2
✓ Branch 0 taken 74516 times.
✓ Branch 1 taken 8404 times.
82920 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5718 {
5719
1/2
✓ Branch 0 taken 74516 times.
✗ Branch 1 not taken.
74516 if(!p_getc(&tempbyte,f))
5720 {
5721 return qe_invalid;
5722 }
5723
2/2
✓ Branch 0 taken 10653 times.
✓ Branch 1 taken 63863 times.
74516 if (keepdata)
5724 63863 temp_misc.warp[i].scr[j] = tempbyte;
5725 74516 }
5726
5727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8404 times.
8404 if(!p_getc(&tempbyte,f))
5728 {
5729 return qe_invalid;
5730 }
5731
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 7176 times.
8404 if (keepdata)
5732 7176 temp_misc.warp[i].size = tempbyte;
5733
5734
2/2
✓ Branch 0 taken 8212 times.
✓ Branch 1 taken 192 times.
8404 if(Header->zelda_version < 0x193)
5735 {
5736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5737 {
5738 return qe_invalid;
5739 }
5740 192 }
5741 8404 }
5742
5743 //palette cycles
5744
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5745 {
5746
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5747 {
5748
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5749 {
5750 18432 temp_misc.cycles[i][j].first=0;
5751 18432 temp_misc.cycles[i][j].count=0;
5752 18432 temp_misc.cycles[i][j].speed=0;
5753 18432 }
5754 6144 }
5755
5756
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5757
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5758 {
5759 18 palcycles=16;
5760 18 }
5761
5762
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5763 {
5764
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5765 {
5766
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5767 {
5768 return qe_invalid;
5769 }
5770
5771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5772 {
5773 return qe_invalid;
5774 }
5775
5776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5777 {
5778 return qe_invalid;
5779 }
5780 5472 }
5781 1824 }
5782 24 }
5783
5784 //Wind warps are now just another warp ring.
5785
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
804 if(s_version <= 5)
5786 {
5787
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5788 {
5789
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5790 {
5791 return qe_invalid;
5792 }
5793 59 }
5794
5795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5796 {
5797 return qe_invalid;
5798 }
5799
5800
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5801 {
5802
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5803 {
5804
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5805 {
5806 return qe_invalid;
5807 }
5808
5809 665 temp_misc.warp[8].dmap[i]=tempbyte;
5810 665 }
5811 else
5812 {
5813 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5814 {
5815 return qe_invalid;
5816 }
5817 }
5818
5819
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5820 {
5821 return qe_invalid;
5822 }
5823
5824 665 temp_misc.warp[8].size = 9;
5825
5826
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5827 {
5828 if(!p_getc(&tempbyte,f))
5829 {
5830 return qe_invalid;
5831 }
5832 }
5833 665 }
5834 83 }
5835
5836
5837 //triforce pieces
5838
2/2
✓ Branch 0 taken 6432 times.
✓ Branch 1 taken 804 times.
7236 for(int32_t i=0; i<triforces; i++)
5839 {
5840
1/2
✓ Branch 0 taken 6432 times.
✗ Branch 1 not taken.
6432 if(!p_getc(&temp_misc.triforce[i],f))
5841 {
5842 return qe_invalid;
5843 }
5844 6432 }
5845
5846 //misc color data
5847
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
804 if(s_version<3)
5848 {
5849
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5850 {
5851 return qe_invalid;
5852 }
5853
5854
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5855 {
5856 return qe_invalid;
5857 }
5858
5859
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5860 {
5861 return qe_invalid;
5862 }
5863
5864
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5865 {
5866 return qe_invalid;
5867 }
5868
5869
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5870 {
5871 return qe_invalid;
5872 }
5873
5874
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5875 {
5876 return qe_invalid;
5877 }
5878
5879
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5880 {
5881 return qe_invalid;
5882 }
5883
5884
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5885 {
5886 return qe_invalid;
5887 }
5888
5889
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5890 {
5891 return qe_invalid;
5892 }
5893
5894
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5895 {
5896 return qe_invalid;
5897 }
5898
5899
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5900 {
5901 return qe_invalid;
5902 }
5903
5904
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5905 {
5906 return qe_invalid;
5907 }
5908
5909
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5910 {
5911 return qe_invalid;
5912 }
5913
5914
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5915 {
5916 return qe_invalid;
5917 }
5918
5919
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5925 {
5926 return qe_invalid;
5927 }
5928
5929
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5930 {
5931 return qe_invalid;
5932 }
5933
5934
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5935 {
5936 return qe_invalid;
5937 }
5938
5939
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5940 {
5941 return qe_invalid;
5942 }
5943
5944
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5945 {
5946 return qe_invalid;
5947 }
5948
5949
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5950 {
5951 return qe_invalid;
5952 }
5953
5954
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5955 {
5956 return qe_invalid;
5957 }
5958
5959
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5960 {
5961 return qe_invalid;
5962 }
5963
5964
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5965 {
5966 return qe_invalid;
5967 }
5968
5969
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5970 {
5971 return qe_invalid;
5972 }
5973
5974
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5975 {
5976 return qe_invalid;
5977 }
5978
5979
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5980 {
5981 return qe_invalid;
5982 }
5983
5984 83 temp_misc.colors.msgtext = 0x01;
5985
5986
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5987 {
5988
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5989 {
5990
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5991 {
5992 return qe_invalid;
5993 }
5994 168 }
5995 24 }
5996
5997
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
5998 {
5999
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6000 {
6001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6002 {
6003 return qe_invalid;
6004 }
6005 1536 }
6006 6 }
6007
6008
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6009 {
6010 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6011 {
6012 return qe_invalid;
6013 }
6014 }
6015
6016 //save game icons
6017
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6018
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6019 {
6020 18 icons=3;
6021 18 }
6022
6023
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6024 {
6025
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6026 {
6027 return qe_invalid;
6028 }
6029 314 }
6030 83 }
6031
6032
3/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
810 if((Header->zelda_version < 0x192)||
6033
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 780 times.
786 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6034 {
6035 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6036
6037 18 return 0;
6038 }
6039
6040 //pond information
6041
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 6 times.
786 if(Header->zelda_version < 0x193)
6042 {
6043
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6044 {
6045 pondsize=25;
6046 }
6047
6048
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6049 {
6050
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6051 {
6052
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6053 {
6054 return qe_invalid;
6055
6056 }
6057 6912 }
6058 96 }
6059 6 }
6060
6061 //end string
6062
2/4
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
792 if((Header->zelda_version < 0x192)||
6063
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 780 times.
786 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6064 {
6065 if(!p_getc(&tempbyte,f))
6066 {
6067 return qe_invalid;
6068 }
6069
6070 temp_misc.endstring=tempbyte;
6071
6072 if(!p_getc(&tempbyte,f))
6073 {
6074 return qe_invalid;
6075 }
6076 }
6077 else
6078 {
6079
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(!p_igetw(&temp_misc.endstring,f))
6080 {
6081 return qe_invalid;
6082 }
6083 }
6084
6085 //expansion
6086
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 6 times.
786 if(Header->zelda_version < 0x193)
6087 {
6088
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6089 {
6090 expansionsize=99*2;
6091 }
6092
6093
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6094 {
6095
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6096 {
6097 return qe_invalid;
6098 }
6099 1176 }
6100 6 }
6101 //shops v8
6102
6103
6104
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 198 times.
786 if(s_version >= 8)
6105 {
6106
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 198 times.
2614 for(int32_t i=0; i<shops; i++)
6107 {
6108
2/2
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 2416 times.
9664 for(int32_t j=0; j<3; j++)
6109 {
6110
1/2
✓ Branch 0 taken 7248 times.
✗ Branch 1 not taken.
7248 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6111 return qe_invalid;
6112 7248 }
6113 2416 }
6114 198 }
6115
6116 786 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6117 786 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6118
6119 //v9 includes quest misc[32]
6120 // ... this has been deprecated (2024)
6121
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 198 times.
786 if(s_version >= 9)
6122 {
6123
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 198 times.
6534 for ( int32_t q = 0; q < 32; q++ )
6124 {
6125
1/2
✓ Branch 0 taken 6336 times.
✗ Branch 1 not taken.
6336 if(!p_igetl(&temp_misc.questmisc[q],f))
6126 return qe_invalid;
6127 6336 }
6128 // this was string labels
6129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if (pack_fseek(f, 32 * 128))
6130 return qe_invalid;
6131 198 }
6132
6133
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 11 )
6134 {
6135
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6136 return qe_invalid;
6137 198 }
6138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 else if(s_version < 11 )
6139 {
6140 588 temp_misc.zscript_last_compiled_version = -1;
6141 588 }
6142
6143 786 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6144
6145
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 12)
6146 {
6147 byte spr;
6148
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t q = 0; q < sprMAX; ++q)
6149 {
6150
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&spr,f))
6151 return qe_invalid;
6152 50688 temp_misc.sprites[q] = spr;
6153 50688 }
6154 198 }
6155 else
6156 {
6157 588 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6158 //temp_misc.sprites[sprFALL] = ;
6159 }
6160
6161
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 13)
6162 {
6163
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 198 times.
12870 for(size_t q = 0; q < 64; ++q)
6164 {
6165 12672 bottletype* bt = &(temp_misc.bottle_types[q]);
6166
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6167 return qe_invalid;
6168
2/2
✓ Branch 0 taken 38016 times.
✓ Branch 1 taken 12672 times.
50688 for(size_t j = 0; j < 3; ++j)
6169 {
6170
1/2
✓ Branch 0 taken 38016 times.
✗ Branch 1 not taken.
38016 if (!p_getc(&(bt->counter[j]), f))
6171 return qe_invalid;
6172
1/2
✓ Branch 0 taken 38016 times.
✗ Branch 1 not taken.
38016 if (!p_igetw(&(bt->amount[j]), f))
6173 return qe_invalid;
6174 38016 }
6175
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if (!p_getc(&(bt->flags), f))
6176 return qe_invalid;
6177
1/2
✓ Branch 0 taken 12672 times.
✗ Branch 1 not taken.
12672 if (!p_getc(&(bt->next_type), f))
6178 return qe_invalid;
6179 12672 }
6180
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(size_t q = 0; q < 256; ++q)
6181 {
6182 50688 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6183
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6184 return qe_invalid;
6185
2/2
✓ Branch 0 taken 152064 times.
✓ Branch 1 taken 50688 times.
202752 for(size_t j = 0; j < 3; ++j)
6186 {
6187
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_getc(&(bst->fill[j]), f))
6188 return qe_invalid;
6189
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_igetw(&(bst->comb[j]), f))
6190 return qe_invalid;
6191
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_getc(&(bst->cset[j]), f))
6192 return qe_invalid;
6193
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_igetw(&(bst->price[j]), f))
6194 return qe_invalid;
6195
1/2
✓ Branch 0 taken 152064 times.
✗ Branch 1 not taken.
152064 if (!p_igetw(&(bst->str[j]), f))
6196 return qe_invalid;
6197 152064 }
6198 50688 }
6199 198 }
6200 else
6201 {
6202
2/2
✓ Branch 0 taken 37632 times.
✓ Branch 1 taken 588 times.
38220 for(size_t q = 0; q < 64; ++q)
6203 37632 temp_misc.bottle_types[q].clear();
6204
2/2
✓ Branch 0 taken 150528 times.
✓ Branch 1 taken 588 times.
151116 for(size_t q = 0; q < 256; ++q)
6205 150528 temp_misc.bottle_shop_types[q].clear();
6206 }
6207
6208
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version >= 14)
6209 {
6210 byte msfx;
6211
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t q = 0; q < sfxMAX; ++q)
6212 {
6213
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&msfx,f))
6214 return qe_invalid;
6215 50688 temp_misc.miscsfx[q] = msfx;
6216 50688 }
6217 198 }
6218 else
6219 {
6220 588 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6221 588 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6222 588 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6223 }
6224
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
786 if(s_version < 15)
6225 {
6226 588 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6227 588 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6228 588 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6229 588 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6230 588 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6231 588 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6232 588 }
6233
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 605 times.
786 if(s_version < 16)
6234 {
6235 605 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6236 605 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6237 605 }
6238
6239
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 785 times.
786 if (!should_skip)
6240 785 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6241
6242 786 return 0;
6243 804 }
6244
6245 extern char *item_string[MAXITEMS];
6246 extern const char *old_item_string[iLast];
6247 extern char *weapon_string[MAXWPNS];
6248 extern const char *old_weapon_string[wLast];
6249
6250 481 int32_t readitems(PACKFILE *f, word version, word build)
6251 {
6252
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6253
6254 byte padding;
6255 int32_t dummy;
6256 481 word items_to_read=MAXITEMS;
6257 481 itemdata tempitem;
6258 481 word s_version=0;
6259 word dummy_word;
6260
6261
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(version < 0x186)
6262 {
6263 6 items_to_read=64;
6264 6 }
6265
6266
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(version > 0x192)
6267 {
6268 457 items_to_read=0;
6269
6270 //section version info
6271
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
6272 {
6273 return qe_invalid;
6274 }
6275
6276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (s_version > V_ITEMS)
6277 return qe_version;
6278
6279 457 FFCore.quest_format[vItems] = s_version;
6280
6281
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!read_deprecated_section_cversion(f))
6282 {
6283 return qe_invalid;
6284 }
6285
6286 //section size
6287
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
6288 {
6289 return qe_invalid;
6290 }
6291
6292 //finally... section data
6293
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&items_to_read,f))
6294 {
6295 return qe_invalid;
6296 }
6297
6298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (items_to_read > MAXITEMS)
6299 {
6300 return qe_invalid;
6301 }
6302 457 }
6303
6304
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 83 times.
481 if(s_version>1)
6305 {
6306
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i=0; i<items_to_read; i++)
6307 {
6308 char tempname[64];
6309
6310
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!pfread(tempname, 64, f))
6311 {
6312 return qe_invalid;
6313 }
6314
6315 101888 item_string[i][0] = '\0';
6316 101888 strncat(item_string[i], tempname, 64 - 1);
6317 101888 }
6318 398 }
6319
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6320 {
6321
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6322 {
6323 20992 reset_itemname(i);
6324 20992 }
6325 82 }
6326
6327
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
6328
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMS; i++)
6329 {
6330 122880 itemdata& id = itemsbuf[i];
6331 122880 memset(&id, 0, sizeof(itemdata));
6332 122880 id.count=-1;
6333 122880 id.playsound=WAV_SCALE;
6334 122880 reset_itembuf(&id,i);
6335 123360 }
6336
6337
2/2
✓ Branch 0 taken 111010 times.
✓ Branch 1 taken 481 times.
111491 for(int32_t i=0; i<items_to_read; i++)
6338 {
6339 111010 tempitem = itemdata();
6340 111010 reset_itembuf(&tempitem,i);
6341
6342
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 60322 times.
111010 if ( s_version > 35 ) //expanded tiles
6343 {
6344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.tile,f))
6345 {
6346 return qe_invalid;
6347 }
6348 50688 }
6349 else
6350 {
6351
1/2
✓ Branch 0 taken 60322 times.
✗ Branch 1 not taken.
60322 if(!p_igetw(&tempitem.tile,f))
6352 {
6353 return qe_invalid;
6354 }
6355 }
6356
6357
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.misc_flags,f))
6358 {
6359 return qe_invalid;
6360 }
6361
6362
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.csets,f))
6363 {
6364 return qe_invalid;
6365 }
6366
6367
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.frames,f))
6368 {
6369 return qe_invalid;
6370 }
6371
6372
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.speed,f))
6373 {
6374 return qe_invalid;
6375 }
6376
6377
1/2
✓ Branch 0 taken 111010 times.
✗ Branch 1 not taken.
111010 if(!p_getc(&tempitem.delay,f))
6378 {
6379 return qe_invalid;
6380 }
6381
6382
2/2
✓ Branch 0 taken 106018 times.
✓ Branch 1 taken 4992 times.
111010 if(version < 0x193)
6383 {
6384
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6385 {
6386 return qe_invalid;
6387 }
6388
6389
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6390 {
6391
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6392 256 continue;
6393
6394
3/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4690 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6395 {
6396 case iShield:
6397 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6398 23 break;
6399
6400 case iMShield:
6401 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6402 23 break;
6403
6404 default:
6405 4690 tempitem.ltm=0;
6406 4690 break;
6407 }
6408
6409 4736 tempitem.count=-1;
6410 4736 tempitem.flags=item_none;
6411 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6412 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6413 4736 tempitem.type=0xFF;
6414 4736 tempitem.playsound=WAV_SCALE;
6415 4736 reset_itembuf(&tempitem,i);
6416
6417 4736 itemsbuf[i] = tempitem;
6418
6419 4736 continue;
6420 }
6421 }
6422
6423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106018 times.
106018 if(!p_igetl(&tempitem.ltm,f))
6424 {
6425 return qe_invalid;
6426 }
6427
6428
1/2
✓ Branch 0 taken 106018 times.
✗ Branch 1 not taken.
106018 if(version < 0x193)
6429 {
6430 for(int32_t q=0; q<12; q++)
6431 {
6432 if(!p_getc(&padding,f))
6433 {
6434 return qe_invalid;
6435 }
6436 }
6437 }
6438
6439
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 4130 times.
106018 if(s_version>1)
6440 {
6441
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
101888 if ( s_version >= 31 )
6442 {
6443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.type,f))
6444 {
6445 return qe_invalid;
6446 }
6447 50688 }
6448 else
6449 {
6450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.type,f))
6451 {
6452 return qe_invalid;
6453 }
6454 }
6455
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version < 16)
6456 if(tempitem.type == 0xFF)
6457 tempitem.type = itype_misc;
6458
6459
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.level,f))
6460 {
6461 return qe_invalid;
6462 }
6463
6464
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version>5)
6465 {
6466
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
101888 if(s_version>=31)
6467 {
6468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.power,f))
6469 {
6470 return qe_invalid;
6471 }
6472 50688 }
6473 else
6474 {
6475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.power,f))
6476 {
6477 return qe_invalid;
6478 }
6479 }
6480
6481 //converted flags from 16b to 32b -Z
6482
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version < 41 )
6483 {
6484
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempitem.flags,f))
6485 {
6486 return qe_invalid;
6487 }
6488 51200 }
6489 else
6490 {
6491
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.flags,f))
6492 {
6493 return qe_invalid;
6494 }
6495 }
6496 101888 }
6497 else
6498 {
6499 //tempitem.power = tempitem.fam_type;
6500 char tempchar;
6501
6502 if(!p_getc(&tempchar,f))
6503 {
6504 return qe_invalid;
6505 }
6506
6507 if (tempchar) tempitem.flags |= item_gamedata;
6508 }
6509
6510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.script,f))
6511 {
6512 return qe_invalid;
6513 }
6514
6515
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<=3)
6516 {
6517 if(tempitem.script > NUMSCRIPTITEM)
6518 {
6519 tempitem.script = 0;
6520 }
6521 }
6522
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.count,f))
6524 {
6525 return qe_invalid;
6526 }
6527
6528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.amount,f))
6529 {
6530 return qe_invalid;
6531 }
6532
6533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.collect_script,f))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<=3)
6539 {
6540 if(tempitem.collect_script > NUMSCRIPTITEM)
6541 {
6542 tempitem.collect_script = 0;
6543 }
6544 }
6545
6546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetw(&tempitem.setmax,f))
6547 {
6548 return qe_invalid;
6549 }
6550
6551
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetw(&tempitem.max,f))
6552 {
6553 return qe_invalid;
6554 }
6555
6556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.playsound,f))
6557 {
6558 return qe_invalid;
6559 }
6560
6561
2/2
✓ Branch 0 taken 815104 times.
✓ Branch 1 taken 101888 times.
916992 for(int32_t j=0; j<8; j++)
6562 {
6563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 815104 times.
815104 if(!p_igetl(&tempitem.initiald[j],f))
6564 {
6565 return qe_invalid;
6566 }
6567 815104 }
6568
6569
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 101888 times.
305664 for(int32_t j=0; j<2; j++)
6570 {
6571 byte temp;
6572
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&temp,f))
6573 {
6574 return qe_invalid;
6575 }
6576 203776 }
6577
6578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>4)
6579 {
6580
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version>5)
6581 {
6582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn,f))
6583 {
6584 return qe_invalid;
6585 }
6586
6587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn2,f))
6588 {
6589 return qe_invalid;
6590 }
6591
6592
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn3,f))
6593 {
6594 return qe_invalid;
6595 }
6596
6597
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn4,f))
6598 {
6599 return qe_invalid;
6600 }
6601
6602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>=15)
6603 {
6604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn5,f))
6605 {
6606 return qe_invalid;
6607 }
6608
6609
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn6,f))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn7,f))
6615 {
6616 return qe_invalid;
6617 }
6618
6619
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.wpn8,f))
6620 {
6621 return qe_invalid;
6622 }
6623
6624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn9,f))
6625 {
6626 return qe_invalid;
6627 }
6628
6629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_getc(&tempitem.wpn10,f))
6630 {
6631 return qe_invalid;
6632 }
6633 101888 }
6634
6635
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.pickup_hearts,f))
6636 {
6637 return qe_invalid;
6638 }
6639
6640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version<15)
6641 {
6642 if(!p_igetw(&dummy_word,f))
6643 {
6644 return qe_invalid;
6645 }
6646
6647 tempitem.misc1=dummy_word;
6648
6649 if(!p_igetw(&dummy_word,f))
6650 {
6651 return qe_invalid;
6652 }
6653
6654 tempitem.misc2=dummy_word;
6655 }
6656 else
6657 {
6658
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc1,f))
6659 {
6660 return qe_invalid;
6661 }
6662
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc2,f))
6664 {
6665 return qe_invalid;
6666 }
6667
6668 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6669
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(s_version<24)
6670 {
6671 if(tempitem.type==itype_shield)
6672 {
6673 tempitem.misc1|=sh_script;
6674 }
6675 }
6676 }
6677
6678
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if(s_version < 53)
6679 {
6680 byte tempbyte;
6681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempbyte,f))
6682 {
6683 return qe_invalid;
6684 }
6685 51200 tempitem.cost_amount[0] = tempbyte;
6686 51200 }
6687 else
6688 {
6689
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for(auto q = 0; q < 2; ++q)
6690 {
6691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101376 times.
101376 if(!p_igetw(&tempitem.cost_amount[q],f))
6692 {
6693 return qe_invalid;
6694 }
6695 101376 }
6696 }
6697 101888 }
6698 else
6699 {
6700 char tempchar;
6701
6702 if(!p_getc(&tempchar,f))
6703 {
6704 return qe_invalid;
6705 }
6706
6707 if (tempchar) tempitem.flags |= item_edible;
6708 }
6709
6710 // June 2007: more misc. attributes
6711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version>=12)
6712 {
6713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(s_version<15)
6714 {
6715 if(!p_igetw(&dummy_word,f))
6716 {
6717 return qe_invalid;
6718 }
6719
6720 tempitem.misc3=dummy_word;
6721
6722 if(!p_igetw(&dummy_word,f))
6723 {
6724 return qe_invalid;
6725 }
6726
6727 tempitem.misc4=dummy_word;
6728 }
6729 else
6730 {
6731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc3,f))
6732 {
6733 return qe_invalid;
6734 }
6735
6736
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc4,f))
6737 {
6738 return qe_invalid;
6739 }
6740
6741
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc5,f))
6742 {
6743 return qe_invalid;
6744 }
6745
6746
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc6,f))
6747 {
6748 return qe_invalid;
6749 }
6750
6751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc7,f))
6752 {
6753 return qe_invalid;
6754 }
6755
6756
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc8,f))
6757 {
6758 return qe_invalid;
6759 }
6760
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101888 times.
101888 if(!p_igetl(&tempitem.misc9,f))
6762 {
6763 return qe_invalid;
6764 }
6765
6766
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_igetl(&tempitem.misc10,f))
6767 {
6768 return qe_invalid;
6769 }
6770 }
6771
6772
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!p_getc(&tempitem.usesound,f))
6773 {
6774 return qe_invalid;
6775 }
6776
6777
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
101888 if(s_version >= 49)
6778 {
6779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_getc(&tempitem.usesound2,f))
6780 {
6781 return qe_invalid;
6782 }
6783 50688 }
6784 51200 else tempitem.usesound2 = 0;
6785
6786
3/4
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
101888 if(s_version < 50 && tempitem.type == itype_mirror)
6787 {
6788 //Split continue/dmap warp effect/sfx, port for old
6789 tempitem.misc2 = tempitem.misc1;
6790 tempitem.usesound2 = tempitem.usesound;
6791 }
6792 101888 }
6793 101888 }
6794
6795
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6796 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6797
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6798 {
6799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17664 times.
17664 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6800 {
6801 return qe_invalid;
6802 }
6803
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_getc(&tempitem.weap_data.default_defense,f))
6804 {
6805 return qe_invalid;
6806 }
6807 17664 }
6808
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.weaprange,f))
6809 {
6810 return qe_invalid;
6811 }
6812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.weapduration,f))
6813 {
6814 return qe_invalid;
6815 }
6816
2/2
✓ Branch 0 taken 506880 times.
✓ Branch 1 taken 50688 times.
557568 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6817 {
6818
1/2
✓ Branch 0 taken 506880 times.
✗ Branch 1 not taken.
506880 if(!p_igetl(&tempitem.weap_pattern[q],f))
6819 {
6820 return qe_invalid;
6821 }
6822 506880 }
6823 50688 }
6824
6825
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6826 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.duplicates,f))
6828 {
6829 return qe_invalid;
6830 }
6831
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6832
2/2
✓ Branch 0 taken 141312 times.
✓ Branch 1 taken 17664 times.
158976 for ( int32_t q = 0; q < INITIAL_D; q++ )
6833
1/2
✓ Branch 0 taken 141312 times.
✗ Branch 1 not taken.
141312 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6834 17664 return qe_invalid;
6835
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for ( int32_t q = 0; q < 2; q++ )
6836 {
6837 byte temp;
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101376 times.
101376 if(!p_getc(&temp,f))
6839 {
6840 return qe_invalid;
6841 }
6842 101376 }
6843
6844
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_getc(&tempitem.drawlayer,f))
6845 {
6846 return qe_invalid;
6847 }
6848
6849
6850
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.hxofs,f))
6851 {
6852 return qe_invalid;
6853 }
6854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.hyofs,f))
6855 {
6856 return qe_invalid;
6857 }
6858
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.hxsz,f))
6859 {
6860 return qe_invalid;
6861 }
6862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.hysz,f))
6863 {
6864 return qe_invalid;
6865 }
6866
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.hzsz,f))
6867 {
6868 return qe_invalid;
6869 }
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.xofs,f))
6871 {
6872 return qe_invalid;
6873 }
6874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.yofs,f))
6875 {
6876 return qe_invalid;
6877 }
6878
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6879 {
6880
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hxofs,f))
6881 return qe_invalid;
6882
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hyofs,f))
6883 return qe_invalid;
6884
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hxsz,f))
6885 return qe_invalid;
6886
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hysz,f))
6887 return qe_invalid;
6888
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.hzsz,f))
6889 return qe_invalid;
6890
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.xofs,f))
6891 return qe_invalid;
6892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17664 times.
17664 if(!p_igetl(&tempitem.weap_data.yofs,f))
6893 return qe_invalid;
6894 17664 }
6895
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 17664 times.
50688 if(s_version < 63)
6896
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetw(&tempitem.weap_data.script,f))
6897 return qe_invalid;
6898
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.wpnsprite,f))
6899 {
6900 return qe_invalid;
6901 }
6902 50688 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6903
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for(auto q = 0; q < num_cost_tmr; ++q)
6904 {
6905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101376 times.
101376 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6906 {
6907 return qe_invalid;
6908 }
6909 101376 }
6910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 for(auto q = num_cost_tmr; q < 2; ++q)
6911 tempitem.magiccosttimer[q] = 0;
6912 50688 }
6913
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6914 {
6915 //Item Size FLags, TileWidth, TileHeight
6916
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.overrideFLAGS,f))
6917 {
6918 return qe_invalid;
6919 }
6920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.tilew,f))
6921 {
6922 return qe_invalid;
6923 }
6924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_igetl(&tempitem.tileh,f))
6925 {
6926 return qe_invalid;
6927 }
6928 50688 }
6929
4/4
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 51200 times.
✓ Branch 2 taken 33024 times.
✓ Branch 3 taken 17664 times.
101888 if ( s_version >= 29 && s_version < 63) //! More new vars.
6930 {
6931
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.override_flags,f))
6932 return qe_invalid;
6933
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.tilew,f))
6934 return qe_invalid;
6935
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if(!p_igetl(&tempitem.weap_data.tileh,f))
6936 return qe_invalid;
6937 17664 }
6938
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 30 ) //! More new vars.
6939 {
6940 //Pickup Type
6941
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempitem.pickup,f))
6942 {
6943 return qe_invalid;
6944 }
6945 50688 }
6946
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 32 ) //! More new vars.
6947 {
6948 //Pickup Type
6949
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempitem.pstring,f))
6950 {
6951 return qe_invalid;
6952 }
6953 50688 }
6954
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 33 ) //! More new vars.
6955 {
6956 //Pickup Type
6957
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempitem.pickup_string_flags,f))
6958 {
6959 return qe_invalid;
6960 }
6961 50688 }
6962
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 34 ) //! cost counter
6963 {
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(s_version < 53)
6965 {
6966 if(!p_getc(&tempitem.cost_counter[0],f))
6967 {
6968 return qe_invalid;
6969 }
6970 }
6971 else
6972 {
6973
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for(auto q = 0; q < 2; ++q)
6974 {
6975
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&tempitem.cost_counter[q],f))
6976 {
6977 return qe_invalid;
6978 }
6979 101376 }
6980 }
6981 50688 }
6982
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 44 ) //! sprite scripts
6983 {
6984
2/2
✓ Branch 0 taken 405504 times.
✓ Branch 1 taken 50688 times.
456192 for ( int32_t q = 0; q < 8; q++ )
6985 {
6986
2/2
✓ Branch 0 taken 26357760 times.
✓ Branch 1 taken 405504 times.
26763264 for ( int32_t w = 0; w < 65; w++ )
6987 {
6988
1/2
✓ Branch 0 taken 26357760 times.
✗ Branch 1 not taken.
26357760 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6989 {
6990 return qe_invalid;
6991 }
6992 26357760 }
6993
2/2
✓ Branch 0 taken 264192 times.
✓ Branch 1 taken 141312 times.
405504 if(s_version < 63)
6994
2/2
✓ Branch 0 taken 9185280 times.
✓ Branch 1 taken 141312 times.
9326592 for ( int32_t w = 0; w < 65; w++ )
6995
1/2
✓ Branch 0 taken 9185280 times.
✗ Branch 1 not taken.
9185280 if(!p_getc(&padding,f))
6996 141312 return qe_invalid;
6997
2/2
✓ Branch 0 taken 26357760 times.
✓ Branch 1 taken 405504 times.
26763264 for ( int32_t w = 0; w < 65; w++ )
6998 {
6999
1/2
✓ Branch 0 taken 26357760 times.
✗ Branch 1 not taken.
26357760 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7000 {
7001 return qe_invalid;
7002 }
7003 26357760 }
7004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405504 times.
405504 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7005 {
7006 return qe_invalid;
7007 }
7008
7009 405504 }
7010
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 50688 times.
152064 for ( int32_t q = 0; q < 2; q++ )
7011 {
7012 byte temp;
7013
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&temp,f))
7014 {
7015 return qe_invalid;
7016 }
7017 101376 }
7018 //Pickup Type
7019
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempitem.sprite_script,f))
7020 {
7021 return qe_invalid;
7022 }
7023 50688 }
7024
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 50688 times.
101888 if ( s_version >= 48 ) //! pickup flags
7025 {
7026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
50688 if(!p_getc(&(tempitem.pickupflag),f))
7027 {
7028 return qe_invalid;
7029 }
7030 50688 }
7031
2/2
✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 47360 times.
101888 if ( s_version >= 57 )
7032 {
7033 47360 std::string str;
7034
2/4
✓ Branch 0 taken 47360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47360 times.
✗ Branch 3 not taken.
47360 if(!p_getcstr(&str,f))
7035 return qe_invalid;
7036 47360 strncpy(tempitem.display_name,str.c_str(),255);
7037
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 47360 times.
47360 }
7038 101888 }
7039 else
7040 {
7041 4130 tempitem.count=-1;
7042 4130 tempitem.type=itype_misc;
7043 4130 tempitem.flags=item_none;
7044 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7045 4130 tempitem.playsound=WAV_SCALE;
7046 4130 reset_itembuf(&tempitem,i);
7047 }
7048
7049
4/4
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 59682 times.
✓ Branch 2 taken 33024 times.
✓ Branch 3 taken 13312 times.
106018 if(s_version >= 58 && s_version < 63)
7050 {
7051
2/2
✓ Branch 0 taken 66560 times.
✓ Branch 1 taken 13312 times.
79872 for(int q = 0; q < WPNSPR_MAX; ++q)
7052 {
7053
1/2
✓ Branch 0 taken 66560 times.
✗ Branch 1 not taken.
66560 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7054 return qe_invalid;
7055
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 65280 times.
66560 if(s_version >= 59)
7056
1/2
✓ Branch 0 taken 65280 times.
✗ Branch 1 not taken.
65280 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7057 return qe_invalid;
7058 66560 }
7059 13312 }
7060
7061
2/2
✓ Branch 0 taken 71458 times.
✓ Branch 1 taken 34560 times.
106018 if ( s_version >= 60 )
7062 {
7063
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 1792 times.
34560 if ( s_version >= 65 )
7064 {
7065
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(!p_igetw(&tempitem.pickup_litems,f))
7066 return qe_invalid;
7067 32768 }
7068 else
7069 {
7070
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&padding,f))
7071 return qe_invalid;
7072 1792 tempitem.pickup_litems = word(padding);
7073 }
7074
1/2
✓ Branch 0 taken 34560 times.
✗ Branch 1 not taken.
34560 if(!p_igetw(&tempitem.pickup_litem_level,f))
7075 return qe_invalid;
7076 34560 }
7077
7078
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 71458 times.
106018 if ( s_version >= 62 )
7079 {
7080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34560 times.
34560 if (!p_igetl(&tempitem.moveflags, f))
7081 return qe_invalid;
7082
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 1536 times.
34560 if(s_version < 63)
7083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7084 return qe_invalid;
7085 34560 }
7086 else
7087 {
7088 71458 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7089
3/3
✓ Branch 0 taken 2050 times.
✓ Branch 1 taken 69089 times.
✓ Branch 2 taken 319 times.
71458 switch(tempitem.type)
7090 {
7091 case itype_divinefire:
7092
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 134 times.
319 if(!(tempitem.flags & item_flag3))
7093 134 break;
7094 [[fallthrough]];
7095 case itype_bomb: case itype_sbomb:
7096 case itype_bait: case itype_liftglove:
7097 case itype_candle: case itype_book:
7098 2235 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7099 2235 break;
7100 default:
7101 69089 tempitem.weap_data.moveflags = move_none;
7102 69089 break;
7103 }
7104 }
7105
7106
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 72994 times.
106018 if(s_version >= 63)
7107 {
7108
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(auto ret = read_weap_data(tempitem.weap_data, f))
7109 return ret;
7110 33024 }
7111 else
7112 {
7113
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 72977 times.
72994 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7114
3/3
✓ Branch 0 taken 666 times.
✓ Branch 1 taken 72246 times.
✓ Branch 2 taken 82 times.
72994 switch(tempitem.type)
7115 {
7116 case itype_liftglove:
7117 82 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7118 82 break;
7119 case itype_bomb: case itype_sbomb:
7120 // Moving these over and removing them from itemdata
7121
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 23 times.
666 if(tempitem.flags & item_flag3)
7122 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7123
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 23 times.
666 if(tempitem.flags & item_flag5)
7124 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7125 666 tempitem.flags &= ~(item_flag3|item_flag5);
7126
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 17 times.
666 if(tempitem.misc4)
7127 {
7128 17 tempitem.weap_data.lift_level = tempitem.misc4;
7129 17 tempitem.weap_data.lift_time = tempitem.misc5;
7130 17 tempitem.weap_data.lift_height = tempitem.misc6;
7131 17 tempitem.misc4 = 0;
7132 17 tempitem.misc5 = 0;
7133 17 tempitem.misc6 = 0;
7134 17 }
7135 666 break;
7136 }
7137 }
7138
7139
2/2
✓ Branch 0 taken 73250 times.
✓ Branch 1 taken 32768 times.
106018 if (s_version >= 64)
7140 {
7141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32768 times.
32768 if (!p_igetl(&tempitem.cooldown, f))
7142 return qe_invalid;
7143 32768 }
7144
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106018 times.
106018 if (!should_skip)
7146 {
7147
1/2
✓ Branch 0 taken 106018 times.
✗ Branch 1 not taken.
106018 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7148 {
7149 tempitem.script = 0;
7150 tempitem.weap_data.script = 0;
7151 for(int q = 0; q < 8; ++q)
7152 {
7153 tempitem.initiald[q] = 0;
7154 tempitem.weap_data.initd[q] = 0;
7155 }
7156 }
7157 106018 itemsbuf[i] = tempitem;
7158 106018 }
7159 106018 }
7160
7161
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (should_skip)
7162 1 return 0;
7163
7164 //////////////////////////////////////////////////////
7165 // Now do any updates because of new item additions
7166 // (These can't be done above because items_to_read
7167 // might be too low.)
7168 //////////////////////////////////////////////////////
7169
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMS; i++)
7170 {
7171 122880 tempitem = itemsbuf[i];
7172
7173 //Account for older quests that didn't have an actual item for the used letter
7174
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 2 && i==iLetterUsed)
7175 {
7176 82 reset_itembuf(&tempitem, iLetterUsed);
7177 82 strcpy(item_string[i],old_item_string[i]);
7178 82 tempitem.tile = itemsbuf[iLetter].tile;
7179 82 tempitem.csets = itemsbuf[iLetter].csets;
7180 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7181 82 tempitem.frames = itemsbuf[iLetter].frames;
7182 82 tempitem.speed = itemsbuf[iLetter].speed;
7183 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7184 82 }
7185
7186
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 3)
7187 {
7188
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7189 {
7190 case iRocsFeather:
7191 case iHoverBoots:
7192 case iSpinScroll:
7193 case iL2SpinScroll:
7194 case iCrossScroll:
7195 case iQuakeScroll:
7196 case iL2QuakeScroll:
7197 case iWhispRing:
7198 case iL2WhispRing:
7199 case iChargeRing:
7200 case iL2ChargeRing:
7201 case iPerilScroll:
7202 case iWalletL3:
7203 case iQuiverL4:
7204 case iBombBagL4:
7205 case iBracelet:
7206 case iL2Bracelet:
7207 case iOldGlove:
7208 case iL2Ladder:
7209 case iWealthMedal:
7210 case iL2WealthMedal:
7211 case iL3WealthMedal:
7212 1804 reset_itembuf(&tempitem, i);
7213 1804 strcpy(item_string[i],old_item_string[i]);
7214 1804 break;
7215
7216 case iSShield:
7217 82 reset_itembuf(&tempitem, i);
7218 82 strcpy(item_string[i],old_item_string[i]);
7219 82 strcpy(item_string[iShield],old_item_string[iShield]);
7220 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7221 82 break;
7222 }
7223 20992 }
7224
7225
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 5)
7226 {
7227
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7228 {
7229 case iHeartRing:
7230 case iL2HeartRing:
7231 case iL3HeartRing:
7232 case iMagicRing:
7233 case iL2MagicRing:
7234 case iL3MagicRing:
7235 case iL4MagicRing:
7236 574 reset_itembuf(&tempitem, i);
7237 574 strcpy(item_string[i],old_item_string[i]);
7238 574 break;
7239 }
7240 20992 }
7241
7242
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7243 {
7244
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7245
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7246
7247
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7248 {
7249 case iTriforce:
7250 82 tempitem.level=1;
7251 82 break;
7252
7253 case iBigTri:
7254 82 tempitem.level=0;
7255 82 break;
7256
7257 case iBombs:
7258 82 tempitem.level=i_bomb;
7259 82 tempitem.power=4;
7260 82 tempitem.wpn=wBOMB;
7261 82 tempitem.wpn2=wBOOM;
7262 82 tempitem.misc1 = 50;
7263
7264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7265
7266 82 break;
7267
7268 case iSBomb:
7269 82 tempitem.level=i_sbomb;
7270 82 tempitem.power=16;
7271 82 tempitem.wpn=wSBOMB;
7272 82 tempitem.wpn2=wSBOOM;
7273 82 tempitem.misc1 = 50;
7274
7275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7276
7277 82 break;
7278
7279 case iBook:
7280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7281 tempitem.wpn = wFIREMAGIC;
7282
7283 82 break;
7284
7285 case iSArrow:
7286 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7287 82 tempitem.power=4;
7288 82 tempitem.flags|=item_gamedata;
7289 82 tempitem.wpn=wSARROW;
7290 82 break;
7291
7292 case iGArrow:
7293 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7294 82 tempitem.power=8;
7295 82 tempitem.flags|=(item_gamedata|item_flag1);
7296 82 tempitem.wpn=wGARROW;
7297 82 break;
7298
7299 case iBrang:
7300 82 tempitem.power=0;
7301 82 tempitem.wpn=wBRANG;
7302 82 tempitem.misc1=36;
7303 82 break;
7304
7305 case iMBrang:
7306 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7307 82 tempitem.power=0;
7308 82 tempitem.wpn=wMBRANG;
7309 82 break;
7310
7311 case iFBrang:
7312 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7313 82 tempitem.power=2;
7314 82 tempitem.wpn=wFBRANG;
7315 82 break;
7316
7317 case iBoots:
7318 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7319 82 tempitem.power=7;
7320 82 break;
7321
7322 case iWand:
7323 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7324 82 tempitem.power=2;
7325 82 tempitem.wpn=wWAND;
7326 82 tempitem.wpn3=wMAGIC;
7327 82 break;
7328
7329 case iBCandle:
7330 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7331 82 tempitem.power=1;
7332 82 tempitem.flags|=(item_gamedata|item_flag1);
7333 82 tempitem.wpn3=wFIRE;
7334 82 break;
7335
7336 case iRCandle:
7337 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7338 82 tempitem.power=1;
7339 82 tempitem.wpn3=wFIRE;
7340 82 break;
7341
7342 case iSword:
7343 82 tempitem.power=1;
7344 82 tempitem.flags|= item_flag4 |item_flag2;
7345 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7346 82 tempitem.wpn2=wSWORDSLASH;
7347 82 break;
7348
7349 case iWSword:
7350 82 tempitem.power=2;
7351 82 tempitem.flags|= item_flag4 |item_flag2;
7352 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7353 82 tempitem.wpn2=wWSWORDSLASH;
7354 82 break;
7355
7356 case iMSword:
7357 82 tempitem.power=4;
7358 82 tempitem.flags|= item_flag4 |item_flag2;
7359 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7360 82 tempitem.wpn2=wMSWORDSLASH;
7361 82 break;
7362
7363 case iXSword:
7364 82 tempitem.power=8;
7365 82 tempitem.flags|= item_flag4 |item_flag2;
7366 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7367 82 tempitem.wpn2=wXSWORDSLASH;
7368 82 break;
7369
7370 case iDivineProtection:
7371 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7372 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7373 82 tempitem.wpn=wDIVINEPROTECTION1A;
7374 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7375 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7376 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7377 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7378 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7379 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7380 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7381 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7382 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7383 82 tempitem.misc1=512;
7384 82 tempitem.cost_amount[0]=64;
7385 82 break;
7386
7387 case iLens:
7388 82 tempitem.misc1=60;
7389 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7390 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7391 82 break;
7392
7393 case iArrow:
7394 82 tempitem.power=2;
7395 82 tempitem.wpn=wARROW;
7396 82 break;
7397
7398 case iHoverBoots:
7399 82 tempitem.misc1=45;
7400 82 tempitem.wpn=iwHover;
7401 82 break;
7402
7403 case iDivineFire:
7404 82 tempitem.power=8;
7405 82 tempitem.wpn=wDIVINEFIRE1A;
7406 82 tempitem.wpn2=wDIVINEFIRE1B;
7407 82 tempitem.wpn3=wDIVINEFIRES1A;
7408 82 tempitem.wpn4=wDIVINEFIRES1B;
7409 82 tempitem.misc1 = 32;
7410 82 tempitem.misc2 = 200;
7411 82 tempitem.cost_amount[0]=32;
7412 82 break;
7413
7414 case iDivineEscape:
7415 82 tempitem.cost_amount[0]=32;
7416 82 break;
7417
7418 case iHookshot:
7419 82 tempitem.power=0;
7420 82 tempitem.flags&=~item_flag1;
7421 82 tempitem.wpn=wHSHEAD;
7422 82 tempitem.wpn2=wHSCHAIN_H;
7423 82 tempitem.wpn4=wHSHANDLE;
7424 82 tempitem.wpn3=wHSCHAIN_V;
7425 82 tempitem.misc1=50;
7426 82 tempitem.misc2=100;
7427 82 break;
7428
7429 case iLongshot:
7430 82 tempitem.power=0;
7431 82 tempitem.flags&=~item_flag1;
7432 82 tempitem.wpn=wLSHEAD;
7433 82 tempitem.wpn2=wLSCHAIN_H;
7434 82 tempitem.wpn4=wLSHANDLE;
7435 82 tempitem.wpn3=wLSCHAIN_V;
7436 82 tempitem.misc1=99;
7437 82 tempitem.misc2=100;
7438 82 break;
7439
7440 case iHammer:
7441 82 tempitem.power=4;
7442 82 tempitem.wpn=wHAMMER;
7443 82 tempitem.wpn2=iwHammerSmack;
7444 82 break;
7445
7446 case iCByrna:
7447 82 tempitem.power=1;
7448 82 tempitem.wpn=wCBYRNA;
7449 82 tempitem.wpn2=wCBYRNASLASH;
7450 82 tempitem.wpn3=wCBYRNAORB;
7451 82 tempitem.misc1=4;
7452 82 tempitem.misc2=16;
7453 82 tempitem.misc3=1;
7454 82 tempitem.cost_amount[0]=1;
7455 82 break;
7456
7457 case iWhistle:
7458 82 tempitem.wpn=wWIND;
7459 82 tempitem.misc1=3;
7460 82 tempitem.flags|=item_flag1;
7461 82 break;
7462
7463 case iBRing:
7464 82 tempitem.power=2;
7465 82 tempitem.misc1=spBLUE;
7466 82 break;
7467
7468 case iRRing:
7469 82 tempitem.power=4;
7470 82 tempitem.misc1=spRED;
7471 82 break;
7472
7473 case iGRing:
7474 82 tempitem.power=8;
7475 82 tempitem.misc1=spGOLD;
7476 82 break;
7477
7478 case iSpinScroll:
7479 82 tempitem.power = 2;
7480 82 tempitem.misc1 = 1;
7481 82 break;
7482
7483 case iL2SpinScroll:
7484 82 tempitem.type=itype_spinscroll2;
7485 82 tempitem.level=1;
7486 82 tempitem.cost_amount[0]=8;
7487 82 tempitem.power=2;
7488 82 tempitem.misc1 = 20;
7489 82 break;
7490
7491 case iQuakeScroll:
7492 82 tempitem.misc1=0x10;
7493 82 tempitem.misc2=64;
7494 82 break;
7495
7496 case iL2QuakeScroll:
7497 82 tempitem.type=itype_quakescroll2;
7498 82 tempitem.level=1;
7499 82 tempitem.power = 2;
7500 82 tempitem.misc1=0x20;
7501 82 tempitem.misc2=192;
7502 82 tempitem.cost_amount[0]=8;
7503 82 break;
7504
7505 case iChargeRing:
7506 82 tempitem.misc1=64;
7507 82 tempitem.misc2=128;
7508 82 break;
7509
7510 case iL2ChargeRing:
7511 82 tempitem.misc1=32;
7512 82 tempitem.misc2=64;
7513 82 break;
7514
7515 case iOldGlove:
7516 82 tempitem.flags |= item_flag1;
7517
7518 //fallthrough
7519 case iBombBagL4:
7520 case iWalletL3:
7521 case iQuiverL4:
7522 case iBracelet:
7523 410 tempitem.power = 1;
7524 410 break;
7525
7526 case iL2Bracelet:
7527 82 tempitem.power = 2;
7528 82 break;
7529
7530 case iMKey:
7531 82 tempitem.power=0xFF;
7532 82 tempitem.flags |= item_flag1;
7533 82 break;
7534 }
7535 20992 }
7536
7537
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 7)
7538 {
7539
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7540 {
7541 case iStoneAgony:
7542 case iStompBoots:
7543 case iPerilRing:
7544 case iWhimsicalRing:
7545 {
7546 328 reset_itembuf(&tempitem, i);
7547 328 strcpy(item_string[i],old_item_string[i]);
7548 328 break;
7549 }
7550 }
7551 20992 }
7552
7553
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 8) // May 2007: Some corrections.
7554 {
7555
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7556 {
7557 case iMShield:
7558 82 tempitem.misc1|=sh_flame;
7559 82 tempitem.misc2|=sh_fireball|sh_magic;
7560
7561
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7562 {
7563 tempitem.misc2 |= sh_sword;
7564 }
7565
7566 // fallthrough
7567 case iShield:
7568 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7569
7570 // fallthrough
7571 case iSShield:
7572 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7573
7574
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7575 {
7576 tempitem.misc2 |= sh_rock;
7577 }
7578
7579 246 break;
7580
7581 case iWhispRing:
7582 82 tempitem.power=1;
7583 82 tempitem.flags|=item_gamedata|item_flag1;
7584 82 tempitem.misc1 = 3;
7585 82 break;
7586
7587 case iL2WhispRing:
7588 82 tempitem.power=0;
7589 82 tempitem.flags|=item_gamedata|item_flag1;
7590 82 tempitem.misc1 = 3;
7591 82 break;
7592
7593 case iL2Ladder:
7594 case iBow:
7595 case iCByrna:
7596 246 tempitem.power = 1;
7597 246 break;
7598 }
7599 20992 }
7600
7601
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 9 && i==iClock)
7602 {
7603 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7604 82 }
7605
7606 //add the misc flag for bomb
7607
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
122880 if(s_version < 10 && tempitem.type == itype_bomb)
7608 {
7609 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7610 82 }
7611
7612
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 101888 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
122880 if(s_version < 11 && tempitem.type == itype_triforcepiece)
7613 {
7614 164 tempitem.flags = (tempitem.level ? item_gamedata : item_none);
7615 164 tempitem.playsound = (tempitem.level ? WAV_SCALE : WAV_CLEARED);
7616 164 }
7617
7618
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 12) // June 2007: More Misc. attributes.
7619 {
7620
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7621 {
7622 case iFBrang:
7623 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7624
7625 //fallthrough
7626 case iMBrang:
7627 164 tempitem.misc3 |= sh_sword|sh_magic;
7628
7629 //fallthrough
7630 case iHookshot:
7631 case iLongshot:
7632 //fallthrough
7633 328 tempitem.misc3 |= sh_fireball;
7634
7635 case iBrang:
7636 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7637 410 break;
7638 }
7639
7640
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 328 times.
✓ Branch 10 taken 164 times.
✓ Branch 11 taken 9629 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.type)
7641 {
7642 case itype_hoverboots:
7643 82 tempitem.usesound = WAV_ZN1HOVER;
7644 82 break;
7645
7646 case itype_wand:
7647 82 tempitem.usesound = WAV_WAND;
7648 82 break;
7649
7650 case itype_book:
7651 82 tempitem.usesound = WAV_FIRE;
7652 82 break;
7653
7654 case itype_arrow:
7655 246 tempitem.usesound = WAV_ARROW;
7656 246 break;
7657
7658 case itype_hookshot:
7659 164 tempitem.usesound = WAV_HOOKSHOT;
7660 164 break;
7661
7662 case itype_brang:
7663 246 tempitem.usesound = WAV_BRANG;
7664 246 break;
7665
7666 case itype_shield:
7667 246 tempitem.usesound = WAV_CHINK;
7668 246 break;
7669
7670 case itype_sword:
7671 9313 tempitem.usesound = WAV_SWORD;
7672 9313 break;
7673
7674 case itype_whistle:
7675 82 tempitem.usesound = WAV_WHISTLE;
7676 82 break;
7677
7678 case itype_hammer:
7679 82 tempitem.usesound = WAV_HAMMER;
7680 82 break;
7681
7682 case itype_divinefire:
7683 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7684 82 break;
7685
7686 case itype_divineescape:
7687 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7688 82 break;
7689
7690 case itype_divineprotection:
7691 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7692 82 break;
7693
7694 case itype_bomb:
7695 case itype_sbomb:
7696 case itype_quakescroll:
7697 case itype_quakescroll2:
7698 328 tempitem.usesound = WAV_BOMB;
7699 328 break;
7700
7701 case itype_spinscroll:
7702 case itype_spinscroll2:
7703 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7704 164 break;
7705 }
7706 20992 }
7707
7708
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 13) // July 2007
7709 {
7710
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7711 {
7712 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7713 82 tempitem.power = 1;
7714 82 tempitem.flags|=item_flag1;
7715 82 }
7716
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_wand)
7717 82 tempitem.flags|=item_flag1;
7718
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.type == itype_book)
7719 {
7720 82 tempitem.flags|=item_flag1;
7721 82 tempitem.power = 2;
7722 82 }
7723 20992 }
7724
7725
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 14) // August 2007
7726 {
7727
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.type == itype_fairy)
7728 {
7729 164 tempitem.usesound = WAV_SCALE;
7730
7731
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.level)
7732 164 tempitem.misc3=50;
7733 164 }
7734
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_potion)
7735 {
7736 164 tempitem.flags |= item_gain_old;
7737 164 }
7738 20992 }
7739
7740
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 17) // November 2007
7741 {
7742
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.type == itype_candle && !tempitem.wpn3)
7743 {
7744 tempitem.wpn3 = wFIRE;
7745 }
7746
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.type == itype_arrow && tempitem.power>4)
7747 {
7748 82 tempitem.flags|=item_flag1;
7749 82 }
7750 20992 }
7751
7752
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 18) // New Year's Eve 2007
7753 {
7754
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7755 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7756
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_bait)
7757 82 tempitem.misc1 = 768; // Frames until it goes
7758
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_triforcepiece)
7759 {
7760
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7761 {
7762 82 tempitem.misc2 = 1; // Cutscene 1
7763 82 tempitem.flags |= item_flag1; // Side Warp Out
7764 82 }
7765 164 }
7766 20992 }
7767
7768
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 19) // January 2008
7769 {
7770
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7771 {
7772
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7773
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7774 82 }
7775 20992 }
7776
7777
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 20) // October 2008
7778 {
7779
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7780 {
7781 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7782 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7783 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7784 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7785 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7786 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7787 82 }
7788 20992 }
7789
7790
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 21) // November 2008
7791 {
7792
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7793 {
7794 tempitem.flags &= ~item_unused;
7795
7796 if(tempitem.type == itype_sword ||
7797 tempitem.type == itype_wand ||
7798 tempitem.type == itype_candle ||
7799 tempitem.type == itype_cbyrna)
7800 {
7801 tempitem.flags |= item_flag4;
7802 }
7803 }
7804 20992 }
7805
7806
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 22) // September 2009
7807 {
7808
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.type == itype_sbomb || tempitem.type == itype_bomb)
7809 {
7810 164 tempitem.misc3 = tempitem.power/2;
7811 164 }
7812 20992 }
7813
7814
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 23) // March 2011
7815 {
7816
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_divinefire)
7817 82 tempitem.wpn5 = wFIRE;
7818
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.type == itype_book)
7819 82 tempitem.wpn2 = wFIRE;
7820 20992 }
7821
7822 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7823 // whether it was or not, and a lot of existing quests depended on the
7824 // incorrect behavior.
7825
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 20992 times.
122880 if(s_version < 25) // January 2012
7826 {
7827
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.type == itype_bombbag)
7828 328 tempitem.flags |= item_flag1;
7829
7830
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divinefire)
7831 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7832 20992 }
7833
7834
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7835 {
7836
60/60
✓ Branch 0 taken 17547 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 327 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 558 times.
✓ Branch 7 taken 614 times.
✓ Branch 8 taken 297 times.
✓ Branch 9 taken 917 times.
✓ Branch 10 taken 892 times.
✓ Branch 11 taken 557 times.
✓ Branch 12 taken 858 times.
✓ Branch 13 taken 558 times.
✓ Branch 14 taken 279 times.
✓ Branch 15 taken 558 times.
✓ Branch 16 taken 295 times.
✓ Branch 17 taken 279 times.
✓ Branch 18 taken 846 times.
✓ Branch 19 taken 282 times.
✓ Branch 20 taken 285 times.
✓ Branch 21 taken 560 times.
✓ Branch 22 taken 255 times.
✓ Branch 23 taken 282 times.
✓ Branch 24 taken 279 times.
✓ Branch 25 taken 279 times.
✓ Branch 26 taken 279 times.
✓ Branch 27 taken 295 times.
✓ Branch 28 taken 281 times.
✓ Branch 29 taken 282 times.
✓ Branch 30 taken 279 times.
✓ Branch 31 taken 284 times.
✓ Branch 32 taken 558 times.
✓ Branch 33 taken 1116 times.
✓ Branch 34 taken 780 times.
✓ Branch 35 taken 279 times.
✓ Branch 36 taken 545 times.
✓ Branch 37 taken 1116 times.
✓ Branch 38 taken 279 times.
✓ Branch 39 taken 279 times.
✓ Branch 40 taken 279 times.
✓ Branch 41 taken 279 times.
✓ Branch 42 taken 279 times.
✓ Branch 43 taken 561 times.
✓ Branch 44 taken 558 times.
✓ Branch 45 taken 279 times.
✓ Branch 46 taken 840 times.
✓ Branch 47 taken 843 times.
✓ Branch 48 taken 1128 times.
✓ Branch 49 taken 279 times.
✓ Branch 50 taken 279 times.
✓ Branch 51 taken 279 times.
✓ Branch 52 taken 279 times.
✓ Branch 53 taken 279 times.
✓ Branch 54 taken 306 times.
✓ Branch 55 taken 10652 times.
✓ Branch 56 taken 2872 times.
✓ Branch 57 taken 842 times.
✓ Branch 58 taken 3261 times.
✓ Branch 59 taken 11005 times.
72192 switch(tempitem.type)
7837 {
7838 case itype_sword:
7839 {
7840 17547 tempitem.flags &= ~(item_flag5);
7841 17547 tempitem.misc3 = 0;
7842 17547 tempitem.misc4 = 0;
7843 17547 tempitem.misc5 = 0;
7844 17547 tempitem.misc6 = 0;
7845 17547 tempitem.misc7 = 0;
7846 17547 tempitem.misc8 = 0;
7847 17547 tempitem.misc9 = 0;
7848 17547 tempitem.misc10 = 0;
7849 17547 tempitem.wpn4 = 0;
7850 17547 tempitem.wpn5 = 0;
7851 17547 tempitem.wpn6 = 0;
7852 17547 tempitem.wpn7 = 0;
7853 17547 tempitem.wpn8 = 0;
7854 17547 tempitem.wpn9 = 0;
7855 17547 tempitem.wpn10 = 0;
7856 17547 break;
7857 }
7858 case itype_brang:
7859 {
7860 844 tempitem.flags &= ~(item_flag4 | item_flag5);
7861 844 tempitem.misc2 = 0;
7862 844 tempitem.misc5 = 0;
7863 844 tempitem.misc6 = 0;
7864 844 tempitem.misc7 = 0;
7865 844 tempitem.misc8 = 0;
7866 844 tempitem.misc9 = 0;
7867 844 tempitem.misc10 = 0;
7868 844 tempitem.wpn4 = 0;
7869 844 tempitem.wpn5 = 0;
7870 844 tempitem.wpn6 = 0;
7871 844 tempitem.wpn7 = 0;
7872 844 tempitem.wpn8 = 0;
7873 844 tempitem.wpn9 = 0;
7874 844 tempitem.wpn10 = 0;
7875 844 break;
7876 }
7877 case itype_arrow:
7878 {
7879 831 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7880 831 tempitem.misc2 = 0;
7881 831 tempitem.misc3 = 0;
7882 831 tempitem.misc4 = 0;
7883 831 tempitem.misc5 = 0;
7884 831 tempitem.misc6 = 0;
7885 831 tempitem.misc7 = 0;
7886 831 tempitem.misc8 = 0;
7887 831 tempitem.misc9 = 0;
7888 831 tempitem.misc10 = 0;
7889 831 tempitem.wpn4 = 0;
7890 831 tempitem.wpn5 = 0;
7891 831 tempitem.wpn6 = 0;
7892 831 tempitem.wpn7 = 0;
7893 831 tempitem.wpn8 = 0;
7894 831 tempitem.wpn9 = 0;
7895 831 tempitem.wpn10 = 0;
7896 831 break;
7897 }
7898 case itype_candle:
7899 {
7900 600 tempitem.flags &= ~ (item_flag3 | item_flag5);
7901 600 tempitem.misc1 = 0;
7902 600 tempitem.misc2 = 0;
7903 600 tempitem.misc3 = 0;
7904 600 tempitem.misc4 = 0;
7905 600 tempitem.misc5 = 0;
7906 600 tempitem.misc6 = 0;
7907 600 tempitem.misc7 = 0;
7908 600 tempitem.misc8 = 0;
7909 600 tempitem.misc9 = 0;
7910 600 tempitem.misc10 = 0;
7911 600 tempitem.wpn4 = 0;
7912 600 tempitem.wpn5 = 0;
7913 600 tempitem.wpn6 = 0;
7914 600 tempitem.wpn7 = 0;
7915 600 tempitem.wpn8 = 0;
7916 600 tempitem.wpn9 = 0;
7917 600 tempitem.wpn10 = 0;
7918 600 break;
7919 }
7920 case itype_whistle:
7921 {
7922 327 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7923 327 tempitem.misc3 = 0;
7924 327 tempitem.misc4 = 0;
7925 327 tempitem.misc5 = 0;
7926 327 tempitem.misc6 = 0;
7927 327 tempitem.misc7 = 0;
7928 327 tempitem.misc8 = 0;
7929 327 tempitem.misc9 = 0;
7930 327 tempitem.misc10 = 0;
7931 327 tempitem.wpn2 = 0;
7932 327 tempitem.wpn3 = 0;
7933 327 tempitem.wpn4 = 0;
7934 327 tempitem.wpn5 = 0;
7935 327 tempitem.wpn6 = 0;
7936 327 tempitem.wpn7 = 0;
7937 327 tempitem.wpn8 = 0;
7938 327 tempitem.wpn9 = 0;
7939 327 tempitem.wpn10 = 0;
7940 327 break;
7941 }
7942 case itype_bait:
7943 {
7944 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7945 282 tempitem.misc2 = 0;
7946 282 tempitem.misc3 = 0;
7947 282 tempitem.misc4 = 0;
7948 282 tempitem.misc5 = 0;
7949 282 tempitem.misc6 = 0;
7950 282 tempitem.misc7 = 0;
7951 282 tempitem.misc8 = 0;
7952 282 tempitem.misc9 = 0;
7953 282 tempitem.misc10 = 0;
7954 282 tempitem.wpn2 = 0;
7955 282 tempitem.wpn3 = 0;
7956 282 tempitem.wpn4 = 0;
7957 282 tempitem.wpn5 = 0;
7958 282 tempitem.wpn6 = 0;
7959 282 tempitem.wpn7 = 0;
7960 282 tempitem.wpn8 = 0;
7961 282 tempitem.wpn9 = 0;
7962 282 tempitem.wpn10 = 0;
7963 282 break;
7964 }
7965 case itype_letter:
7966 {
7967 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7968 558 tempitem.misc1 = 0;
7969 558 tempitem.misc2 = 0;
7970 558 tempitem.misc3 = 0;
7971 558 tempitem.misc4 = 0;
7972 558 tempitem.misc5 = 0;
7973 558 tempitem.misc6 = 0;
7974 558 tempitem.misc7 = 0;
7975 558 tempitem.misc8 = 0;
7976 558 tempitem.misc9 = 0;
7977 558 tempitem.misc10 = 0;
7978 558 tempitem.wpn = 0;
7979 558 tempitem.wpn2 = 0;
7980 558 tempitem.wpn3 = 0;
7981 558 tempitem.wpn4 = 0;
7982 558 tempitem.wpn5 = 0;
7983 558 tempitem.wpn6 = 0;
7984 558 tempitem.wpn7 = 0;
7985 558 tempitem.wpn8 = 0;
7986 558 tempitem.wpn9 = 0;
7987 558 tempitem.wpn10 = 0;
7988 558 break;
7989 }
7990 case itype_potion:
7991 {
7992 614 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7993 614 tempitem.misc3 = 0;
7994 614 tempitem.misc4 = 0;
7995 614 tempitem.misc5 = 0;
7996 614 tempitem.misc6 = 0;
7997 614 tempitem.misc7 = 0;
7998 614 tempitem.misc8 = 0;
7999 614 tempitem.misc9 = 0;
8000 614 tempitem.misc10 = 0;
8001 614 tempitem.wpn = 0;
8002 614 tempitem.wpn2 = 0;
8003 614 tempitem.wpn3 = 0;
8004 614 tempitem.wpn4 = 0;
8005 614 tempitem.wpn5 = 0;
8006 614 tempitem.wpn6 = 0;
8007 614 tempitem.wpn7 = 0;
8008 614 tempitem.wpn8 = 0;
8009 614 tempitem.wpn9 = 0;
8010 614 tempitem.wpn10 = 0;
8011 614 break;
8012 }
8013 case itype_wand:
8014 {
8015 297 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8016 297 tempitem.misc1 = 0;
8017 297 tempitem.misc2 = 0;
8018 297 tempitem.misc3 = 0;
8019 297 tempitem.misc4 = 0;
8020 297 tempitem.misc5 = 0;
8021 297 tempitem.misc6 = 0;
8022 297 tempitem.misc7 = 0;
8023 297 tempitem.misc8 = 0;
8024 297 tempitem.misc9 = 0;
8025 297 tempitem.misc10 = 0;
8026 297 tempitem.wpn4 = 0;
8027 297 tempitem.wpn5 = 0;
8028 297 tempitem.wpn6 = 0;
8029 297 tempitem.wpn7 = 0;
8030 297 tempitem.wpn8 = 0;
8031 297 tempitem.wpn9 = 0;
8032 297 tempitem.wpn10 = 0;
8033 297 break;
8034 }
8035 case itype_ring:
8036 {
8037 917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8038 917 tempitem.misc2 = 0;
8039 917 tempitem.misc3 = 0;
8040 917 tempitem.misc4 = 0;
8041 917 tempitem.misc5 = 0;
8042 917 tempitem.misc6 = 0;
8043 917 tempitem.misc7 = 0;
8044 917 tempitem.misc8 = 0;
8045 917 tempitem.misc9 = 0;
8046 917 tempitem.misc10 = 0;
8047 917 tempitem.wpn = 0;
8048 917 tempitem.wpn2 = 0;
8049 917 tempitem.wpn3 = 0;
8050 917 tempitem.wpn4 = 0;
8051 917 tempitem.wpn5 = 0;
8052 917 tempitem.wpn6 = 0;
8053 917 tempitem.wpn7 = 0;
8054 917 tempitem.wpn8 = 0;
8055 917 tempitem.wpn9 = 0;
8056 917 tempitem.wpn10 = 0;
8057 917 break;
8058 }
8059 case itype_wallet:
8060 {
8061 892 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8062 892 tempitem.misc3 = 0;
8063 892 tempitem.misc4 = 0;
8064 892 tempitem.misc5 = 0;
8065 892 tempitem.misc6 = 0;
8066 892 tempitem.misc7 = 0;
8067 892 tempitem.misc8 = 0;
8068 892 tempitem.misc9 = 0;
8069 892 tempitem.misc10 = 0;
8070 892 tempitem.wpn = 0;
8071 892 tempitem.wpn2 = 0;
8072 892 tempitem.wpn3 = 0;
8073 892 tempitem.wpn4 = 0;
8074 892 tempitem.wpn5 = 0;
8075 892 tempitem.wpn6 = 0;
8076 892 tempitem.wpn7 = 0;
8077 892 tempitem.wpn8 = 0;
8078 892 tempitem.wpn9 = 0;
8079 892 tempitem.wpn10 = 0;
8080 892 break;
8081 }
8082 case itype_amulet:
8083 {
8084 557 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8085 557 tempitem.misc1 = 0;
8086 557 tempitem.misc2 = 0;
8087 557 tempitem.misc3 = 0;
8088 557 tempitem.misc4 = 0;
8089 557 tempitem.misc5 = 0;
8090 557 tempitem.misc6 = 0;
8091 557 tempitem.misc7 = 0;
8092 557 tempitem.misc8 = 0;
8093 557 tempitem.misc9 = 0;
8094 557 tempitem.misc10 = 0;
8095 557 tempitem.wpn = 0;
8096 557 tempitem.wpn2 = 0;
8097 557 tempitem.wpn3 = 0;
8098 557 tempitem.wpn4 = 0;
8099 557 tempitem.wpn5 = 0;
8100 557 tempitem.wpn6 = 0;
8101 557 tempitem.wpn7 = 0;
8102 557 tempitem.wpn8 = 0;
8103 557 tempitem.wpn9 = 0;
8104 557 tempitem.wpn10 = 0;
8105 557 break;
8106 }
8107 case itype_shield:
8108 {
8109 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8110 858 tempitem.misc3 = 0;
8111 858 tempitem.misc4 = 0;
8112 858 tempitem.misc5 = 0;
8113 858 tempitem.misc6 = 0;
8114 858 tempitem.misc7 = 0;
8115 858 tempitem.misc8 = 0;
8116 858 tempitem.misc9 = 0;
8117 858 tempitem.misc10 = 0;
8118 858 tempitem.wpn = 0;
8119 858 tempitem.wpn2 = 0;
8120 858 tempitem.wpn3 = 0;
8121 858 tempitem.wpn4 = 0;
8122 858 tempitem.wpn5 = 0;
8123 858 tempitem.wpn6 = 0;
8124 858 tempitem.wpn7 = 0;
8125 858 tempitem.wpn8 = 0;
8126 858 tempitem.wpn9 = 0;
8127 858 tempitem.wpn10 = 0;
8128 858 break;
8129 }
8130 case itype_bow:
8131 {
8132 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8133 558 tempitem.misc1 = 0;
8134 558 tempitem.misc2 = 0;
8135 558 tempitem.misc3 = 0;
8136 558 tempitem.misc4 = 0;
8137 558 tempitem.misc5 = 0;
8138 558 tempitem.misc6 = 0;
8139 558 tempitem.misc7 = 0;
8140 558 tempitem.misc8 = 0;
8141 558 tempitem.misc9 = 0;
8142 558 tempitem.misc10 = 0;
8143 558 tempitem.wpn = 0;
8144 558 tempitem.wpn2 = 0;
8145 558 tempitem.wpn3 = 0;
8146 558 tempitem.wpn4 = 0;
8147 558 tempitem.wpn5 = 0;
8148 558 tempitem.wpn6 = 0;
8149 558 tempitem.wpn7 = 0;
8150 558 tempitem.wpn8 = 0;
8151 558 tempitem.wpn9 = 0;
8152 558 tempitem.wpn10 = 0;
8153 558 break;
8154 }
8155 case itype_raft:
8156 {
8157 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8158 279 tempitem.misc1 = 0;
8159 279 tempitem.misc2 = 0;
8160 279 tempitem.misc3 = 0;
8161 279 tempitem.misc4 = 0;
8162 279 tempitem.misc5 = 0;
8163 279 tempitem.misc6 = 0;
8164 279 tempitem.misc7 = 0;
8165 279 tempitem.misc8 = 0;
8166 279 tempitem.misc9 = 0;
8167 279 tempitem.misc10 = 0;
8168 279 tempitem.wpn = 0;
8169 279 tempitem.wpn2 = 0;
8170 279 tempitem.wpn3 = 0;
8171 279 tempitem.wpn4 = 0;
8172 279 tempitem.wpn5 = 0;
8173 279 tempitem.wpn6 = 0;
8174 279 tempitem.wpn7 = 0;
8175 279 tempitem.wpn8 = 0;
8176 279 tempitem.wpn9 = 0;
8177 279 tempitem.wpn10 = 0;
8178 279 break;
8179 }
8180 case itype_ladder:
8181 {
8182 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8183 558 tempitem.misc1 = 0;
8184 558 tempitem.misc2 = 0;
8185 558 tempitem.misc3 = 0;
8186 558 tempitem.misc4 = 0;
8187 558 tempitem.misc5 = 0;
8188 558 tempitem.misc6 = 0;
8189 558 tempitem.misc7 = 0;
8190 558 tempitem.misc8 = 0;
8191 558 tempitem.misc9 = 0;
8192 558 tempitem.misc10 = 0;
8193 558 tempitem.wpn = 0;
8194 558 tempitem.wpn2 = 0;
8195 558 tempitem.wpn3 = 0;
8196 558 tempitem.wpn4 = 0;
8197 558 tempitem.wpn5 = 0;
8198 558 tempitem.wpn6 = 0;
8199 558 tempitem.wpn7 = 0;
8200 558 tempitem.wpn8 = 0;
8201 558 tempitem.wpn9 = 0;
8202 558 tempitem.wpn10 = 0;
8203 558 break;
8204 }
8205 case itype_book:
8206 {
8207 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8208 295 tempitem.misc1 = 0;
8209 295 tempitem.misc2 = 0;
8210 295 tempitem.misc3 = 0;
8211 295 tempitem.misc4 = 0;
8212 295 tempitem.misc5 = 0;
8213 295 tempitem.misc6 = 0;
8214 295 tempitem.misc7 = 0;
8215 295 tempitem.misc8 = 0;
8216 295 tempitem.misc9 = 0;
8217 295 tempitem.misc10 = 0;
8218 295 tempitem.wpn3 = 0;
8219 295 tempitem.wpn4 = 0;
8220 295 tempitem.wpn5 = 0;
8221 295 tempitem.wpn6 = 0;
8222 295 tempitem.wpn7 = 0;
8223 295 tempitem.wpn8 = 0;
8224 295 tempitem.wpn9 = 0;
8225 295 tempitem.wpn10 = 0;
8226 295 break;
8227 }
8228 case itype_magickey:
8229 {
8230 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8231 279 tempitem.misc1 = 0;
8232 279 tempitem.misc2 = 0;
8233 279 tempitem.misc3 = 0;
8234 279 tempitem.misc4 = 0;
8235 279 tempitem.misc5 = 0;
8236 279 tempitem.misc6 = 0;
8237 279 tempitem.misc7 = 0;
8238 279 tempitem.misc8 = 0;
8239 279 tempitem.misc9 = 0;
8240 279 tempitem.misc10 = 0;
8241 279 tempitem.wpn = 0;
8242 279 tempitem.wpn2 = 0;
8243 279 tempitem.wpn3 = 0;
8244 279 tempitem.wpn4 = 0;
8245 279 tempitem.wpn5 = 0;
8246 279 tempitem.wpn6 = 0;
8247 279 tempitem.wpn7 = 0;
8248 279 tempitem.wpn8 = 0;
8249 279 tempitem.wpn9 = 0;
8250 279 tempitem.wpn10 = 0;
8251 279 break;
8252 }
8253 case itype_bracelet:
8254 {
8255 846 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8256 846 tempitem.misc1 = 0;
8257 846 tempitem.misc2 = 0;
8258 846 tempitem.misc3 = 0;
8259 846 tempitem.misc4 = 0;
8260 846 tempitem.misc5 = 0;
8261 846 tempitem.misc6 = 0;
8262 846 tempitem.misc7 = 0;
8263 846 tempitem.misc8 = 0;
8264 846 tempitem.misc9 = 0;
8265 846 tempitem.misc10 = 0;
8266 846 tempitem.wpn = 0;
8267 846 tempitem.wpn2 = 0;
8268 846 tempitem.wpn3 = 0;
8269 846 tempitem.wpn4 = 0;
8270 846 tempitem.wpn5 = 0;
8271 846 tempitem.wpn6 = 0;
8272 846 tempitem.wpn7 = 0;
8273 846 tempitem.wpn8 = 0;
8274 846 tempitem.wpn9 = 0;
8275 846 tempitem.wpn10 = 0;
8276 846 break;
8277 }
8278 case itype_flippers:
8279 {
8280 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8281 282 tempitem.misc1 = 0;
8282 282 tempitem.misc2 = 0;
8283 282 tempitem.misc3 = 0;
8284 282 tempitem.misc4 = 0;
8285 282 tempitem.misc5 = 0;
8286 282 tempitem.misc6 = 0;
8287 282 tempitem.misc7 = 0;
8288 282 tempitem.misc8 = 0;
8289 282 tempitem.misc9 = 0;
8290 282 tempitem.misc10 = 0;
8291 282 tempitem.wpn = 0;
8292 282 tempitem.wpn2 = 0;
8293 282 tempitem.wpn3 = 0;
8294 282 tempitem.wpn4 = 0;
8295 282 tempitem.wpn5 = 0;
8296 282 tempitem.wpn6 = 0;
8297 282 tempitem.wpn7 = 0;
8298 282 tempitem.wpn8 = 0;
8299 282 tempitem.wpn9 = 0;
8300 282 tempitem.wpn10 = 0;
8301 282 break;
8302 }
8303 case itype_boots:
8304 {
8305 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8306 285 tempitem.misc1 = 0;
8307 285 tempitem.misc2 = 0;
8308 285 tempitem.misc3 = 0;
8309 285 tempitem.misc4 = 0;
8310 285 tempitem.misc5 = 0;
8311 285 tempitem.misc6 = 0;
8312 285 tempitem.misc7 = 0;
8313 285 tempitem.misc8 = 0;
8314 285 tempitem.misc9 = 0;
8315 285 tempitem.misc10 = 0;
8316 285 tempitem.wpn = 0;
8317 285 tempitem.wpn2 = 0;
8318 285 tempitem.wpn3 = 0;
8319 285 tempitem.wpn4 = 0;
8320 285 tempitem.wpn5 = 0;
8321 285 tempitem.wpn6 = 0;
8322 285 tempitem.wpn7 = 0;
8323 285 tempitem.wpn8 = 0;
8324 285 tempitem.wpn9 = 0;
8325 285 tempitem.wpn10 = 0;
8326 285 break;
8327 }
8328 case itype_hookshot:
8329 {
8330 560 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8331 560 tempitem.misc5 = 0;
8332 560 tempitem.misc6 = 0;
8333 560 tempitem.misc7 = 0;
8334 560 tempitem.misc8 = 0;
8335 560 tempitem.misc9 = 0;
8336 560 tempitem.misc10 = 0;
8337 560 tempitem.wpn5 = 0;
8338 560 tempitem.wpn6 = 0;
8339 560 tempitem.wpn7 = 0;
8340 560 tempitem.wpn8 = 0;
8341 560 tempitem.wpn9 = 0;
8342 560 tempitem.wpn10 = 0;
8343 560 break;
8344 }
8345 case itype_lens:
8346 {
8347 255 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8348 255 tempitem.misc2 = 0;
8349 255 tempitem.misc3 = 0;
8350 255 tempitem.misc4 = 0;
8351 255 tempitem.misc5 = 0;
8352 255 tempitem.misc6 = 0;
8353 255 tempitem.misc7 = 0;
8354 255 tempitem.misc8 = 0;
8355 255 tempitem.misc9 = 0;
8356 255 tempitem.misc10 = 0;
8357 255 tempitem.wpn = 0;
8358 255 tempitem.wpn2 = 0;
8359 255 tempitem.wpn3 = 0;
8360 255 tempitem.wpn4 = 0;
8361 255 tempitem.wpn5 = 0;
8362 255 tempitem.wpn6 = 0;
8363 255 tempitem.wpn7 = 0;
8364 255 tempitem.wpn8 = 0;
8365 255 tempitem.wpn9 = 0;
8366 255 tempitem.wpn10 = 0;
8367 255 break;
8368 }
8369 case itype_hammer:
8370 {
8371 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8372 282 tempitem.misc1 = 0;
8373 282 tempitem.misc2 = 0;
8374 282 tempitem.misc3 = 0;
8375 282 tempitem.misc4 = 0;
8376 282 tempitem.misc5 = 0;
8377 282 tempitem.misc6 = 0;
8378 282 tempitem.misc7 = 0;
8379 282 tempitem.misc8 = 0;
8380 282 tempitem.misc9 = 0;
8381 282 tempitem.misc10 = 0;
8382 282 tempitem.wpn3 = 0;
8383 282 tempitem.wpn4 = 0;
8384 282 tempitem.wpn5 = 0;
8385 282 tempitem.wpn6 = 0;
8386 282 tempitem.wpn7 = 0;
8387 282 tempitem.wpn8 = 0;
8388 282 tempitem.wpn9 = 0;
8389 282 tempitem.wpn10 = 0;
8390 282 break;
8391 }
8392 case itype_divinefire:
8393 {
8394 279 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8395 279 tempitem.misc3 = 0;
8396 279 tempitem.misc4 = 0;
8397 279 tempitem.misc5 = 0;
8398 279 tempitem.misc6 = 0;
8399 279 tempitem.misc7 = 0;
8400 279 tempitem.misc8 = 0;
8401 279 tempitem.misc9 = 0;
8402 279 tempitem.misc10 = 0;
8403 279 tempitem.wpn6 = 0;
8404 279 tempitem.wpn7 = 0;
8405 279 tempitem.wpn8 = 0;
8406 279 tempitem.wpn9 = 0;
8407 279 tempitem.wpn10 = 0;
8408 279 break;
8409 }
8410 case itype_divineescape:
8411 {
8412 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8413 279 tempitem.misc2 = 0;
8414 279 tempitem.misc3 = 0;
8415 279 tempitem.misc4 = 0;
8416 279 tempitem.misc5 = 0;
8417 279 tempitem.misc6 = 0;
8418 279 tempitem.misc7 = 0;
8419 279 tempitem.misc8 = 0;
8420 279 tempitem.misc9 = 0;
8421 279 tempitem.misc10 = 0;
8422 279 tempitem.wpn = 0;
8423 279 tempitem.wpn2 = 0;
8424 279 tempitem.wpn3 = 0;
8425 279 tempitem.wpn4 = 0;
8426 279 tempitem.wpn5 = 0;
8427 279 tempitem.wpn6 = 0;
8428 279 tempitem.wpn7 = 0;
8429 279 tempitem.wpn8 = 0;
8430 279 tempitem.wpn9 = 0;
8431 279 tempitem.wpn10 = 0;
8432 279 break;
8433 }
8434 case itype_divineprotection:
8435 {
8436 279 tempitem.flags &= ~ (item_flag5);
8437 279 tempitem.misc2 = 0;
8438 279 tempitem.misc3 = 0;
8439 279 tempitem.misc4 = 0;
8440 279 tempitem.misc5 = 0;
8441 279 tempitem.misc6 = 0;
8442 279 tempitem.misc7 = 0;
8443 279 tempitem.misc8 = 0;
8444 279 tempitem.misc9 = 0;
8445 279 tempitem.misc10 = 0;
8446 279 break;
8447 }
8448 case itype_bomb:
8449 {
8450 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8451 295 tempitem.misc4 = 0;
8452 295 tempitem.misc5 = 0;
8453 295 tempitem.misc6 = 0;
8454 295 tempitem.misc7 = 0;
8455 295 tempitem.misc8 = 0;
8456 295 tempitem.misc9 = 0;
8457 295 tempitem.misc10 = 0;
8458 295 tempitem.wpn3 = 0;
8459 295 tempitem.wpn4 = 0;
8460 295 tempitem.wpn5 = 0;
8461 295 tempitem.wpn6 = 0;
8462 295 tempitem.wpn7 = 0;
8463 295 tempitem.wpn8 = 0;
8464 295 tempitem.wpn9 = 0;
8465 295 tempitem.wpn10 = 0;
8466 295 break;
8467 }
8468 case itype_sbomb:
8469 {
8470 281 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8471 281 tempitem.misc4 = 0;
8472 281 tempitem.misc5 = 0;
8473 281 tempitem.misc6 = 0;
8474 281 tempitem.misc7 = 0;
8475 281 tempitem.misc8 = 0;
8476 281 tempitem.misc9 = 0;
8477 281 tempitem.misc10 = 0;
8478 281 tempitem.wpn3 = 0;
8479 281 tempitem.wpn4 = 0;
8480 281 tempitem.wpn5 = 0;
8481 281 tempitem.wpn6 = 0;
8482 281 tempitem.wpn7 = 0;
8483 281 tempitem.wpn8 = 0;
8484 281 tempitem.wpn9 = 0;
8485 281 tempitem.wpn10 = 0;
8486 281 break;
8487 }
8488 case itype_clock:
8489 {
8490 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8491 282 tempitem.misc2 = 0;
8492 282 tempitem.misc3 = 0;
8493 282 tempitem.misc4 = 0;
8494 282 tempitem.misc5 = 0;
8495 282 tempitem.misc6 = 0;
8496 282 tempitem.misc7 = 0;
8497 282 tempitem.misc8 = 0;
8498 282 tempitem.misc9 = 0;
8499 282 tempitem.misc10 = 0;
8500 282 tempitem.wpn = 0;
8501 282 tempitem.wpn2 = 0;
8502 282 tempitem.wpn3 = 0;
8503 282 tempitem.wpn4 = 0;
8504 282 tempitem.wpn5 = 0;
8505 282 tempitem.wpn6 = 0;
8506 282 tempitem.wpn7 = 0;
8507 282 tempitem.wpn8 = 0;
8508 282 tempitem.wpn9 = 0;
8509 282 tempitem.wpn10 = 0;
8510 282 break;
8511 }
8512 case itype_key:
8513 {
8514 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8515 279 tempitem.misc1 = 0;
8516 279 tempitem.misc2 = 0;
8517 279 tempitem.misc3 = 0;
8518 279 tempitem.misc4 = 0;
8519 279 tempitem.misc5 = 0;
8520 279 tempitem.misc6 = 0;
8521 279 tempitem.misc7 = 0;
8522 279 tempitem.misc8 = 0;
8523 279 tempitem.misc9 = 0;
8524 279 tempitem.misc10 = 0;
8525 279 tempitem.wpn = 0;
8526 279 tempitem.wpn2 = 0;
8527 279 tempitem.wpn3 = 0;
8528 279 tempitem.wpn4 = 0;
8529 279 tempitem.wpn5 = 0;
8530 279 tempitem.wpn6 = 0;
8531 279 tempitem.wpn7 = 0;
8532 279 tempitem.wpn8 = 0;
8533 279 tempitem.wpn9 = 0;
8534 279 tempitem.wpn10 = 0;
8535 279 break;
8536 }
8537 case itype_magiccontainer:
8538 {
8539 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8540 284 tempitem.misc1 = 0;
8541 284 tempitem.misc2 = 0;
8542 284 tempitem.misc3 = 0;
8543 284 tempitem.misc4 = 0;
8544 284 tempitem.misc5 = 0;
8545 284 tempitem.misc6 = 0;
8546 284 tempitem.misc7 = 0;
8547 284 tempitem.misc8 = 0;
8548 284 tempitem.misc9 = 0;
8549 284 tempitem.misc10 = 0;
8550 284 tempitem.wpn = 0;
8551 284 tempitem.wpn2 = 0;
8552 284 tempitem.wpn3 = 0;
8553 284 tempitem.wpn4 = 0;
8554 284 tempitem.wpn5 = 0;
8555 284 tempitem.wpn6 = 0;
8556 284 tempitem.wpn7 = 0;
8557 284 tempitem.wpn8 = 0;
8558 284 tempitem.wpn9 = 0;
8559 284 tempitem.wpn10 = 0;
8560 284 break;
8561 }
8562 case itype_triforcepiece:
8563 {
8564 558 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8565 558 tempitem.misc3 = 0;
8566 558 tempitem.misc4 = 0;
8567 558 tempitem.misc5 = 0;
8568 558 tempitem.misc6 = 0;
8569 558 tempitem.misc7 = 0;
8570 558 tempitem.misc8 = 0;
8571 558 tempitem.misc9 = 0;
8572 558 tempitem.misc10 = 0;
8573 558 tempitem.wpn = 0;
8574 558 tempitem.wpn2 = 0;
8575 558 tempitem.wpn3 = 0;
8576 558 tempitem.wpn4 = 0;
8577 558 tempitem.wpn5 = 0;
8578 558 tempitem.wpn6 = 0;
8579 558 tempitem.wpn7 = 0;
8580 558 tempitem.wpn8 = 0;
8581 558 tempitem.wpn9 = 0;
8582 558 tempitem.wpn10 = 0;
8583 558 break;
8584 }
8585 case itype_map: case itype_compass: case itype_bosskey:
8586 {
8587 842 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8588 842 tempitem.misc1 = 0;
8589 842 tempitem.misc2 = 0;
8590 842 tempitem.misc3 = 0;
8591 842 tempitem.misc4 = 0;
8592 842 tempitem.misc5 = 0;
8593 842 tempitem.misc6 = 0;
8594 842 tempitem.misc7 = 0;
8595 842 tempitem.misc8 = 0;
8596 842 tempitem.misc9 = 0;
8597 842 tempitem.misc10 = 0;
8598 842 tempitem.wpn = 0;
8599 842 tempitem.wpn2 = 0;
8600 842 tempitem.wpn3 = 0;
8601 842 tempitem.wpn4 = 0;
8602 842 tempitem.wpn5 = 0;
8603 842 tempitem.wpn6 = 0;
8604 842 tempitem.wpn7 = 0;
8605 842 tempitem.wpn8 = 0;
8606 842 tempitem.wpn9 = 0;
8607 842 tempitem.wpn10 = 0;
8608 842 break;
8609 }
8610 case itype_quiver:
8611 {
8612 1116 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8613 1116 tempitem.misc3 = 0;
8614 1116 tempitem.misc4 = 0;
8615 1116 tempitem.misc5 = 0;
8616 1116 tempitem.misc6 = 0;
8617 1116 tempitem.misc7 = 0;
8618 1116 tempitem.misc8 = 0;
8619 1116 tempitem.misc9 = 0;
8620 1116 tempitem.misc10 = 0;
8621 1116 tempitem.wpn = 0;
8622 1116 tempitem.wpn2 = 0;
8623 1116 tempitem.wpn3 = 0;
8624 1116 tempitem.wpn4 = 0;
8625 1116 tempitem.wpn5 = 0;
8626 1116 tempitem.wpn6 = 0;
8627 1116 tempitem.wpn7 = 0;
8628 1116 tempitem.wpn8 = 0;
8629 1116 tempitem.wpn9 = 0;
8630 1116 tempitem.wpn10 = 0;
8631 1116 break;
8632 }
8633 case itype_lkey:
8634 {
8635 780 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8636 780 tempitem.misc1 = 0;
8637 780 tempitem.misc2 = 0;
8638 780 tempitem.misc3 = 0;
8639 780 tempitem.misc4 = 0;
8640 780 tempitem.misc5 = 0;
8641 780 tempitem.misc6 = 0;
8642 780 tempitem.misc7 = 0;
8643 780 tempitem.misc8 = 0;
8644 780 tempitem.misc9 = 0;
8645 780 tempitem.misc10 = 0;
8646 780 tempitem.wpn = 0;
8647 780 tempitem.wpn2 = 0;
8648 780 tempitem.wpn3 = 0;
8649 780 tempitem.wpn4 = 0;
8650 780 tempitem.wpn5 = 0;
8651 780 tempitem.wpn6 = 0;
8652 780 tempitem.wpn7 = 0;
8653 780 tempitem.wpn8 = 0;
8654 780 tempitem.wpn9 = 0;
8655 780 tempitem.wpn10 = 0;
8656 780 break;
8657 }
8658 case itype_cbyrna:
8659 {
8660 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8661 279 tempitem.misc4 = 0;
8662 279 tempitem.misc5 = 0;
8663 279 tempitem.misc6 = 0;
8664 279 tempitem.misc7 = 0;
8665 279 tempitem.misc8 = 0;
8666 279 tempitem.misc9 = 0;
8667 279 tempitem.misc10 = 0;
8668 279 tempitem.wpn6 = 0;
8669 279 tempitem.wpn7 = 0;
8670 279 tempitem.wpn8 = 0;
8671 279 tempitem.wpn9 = 0;
8672 279 tempitem.wpn10 = 0;
8673 279 break;
8674 }
8675 case itype_rupee: case itype_arrowammo:
8676 {
8677 3261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8678 3261 tempitem.misc1 = 0;
8679 3261 tempitem.misc2 = 0;
8680 3261 tempitem.misc3 = 0;
8681 3261 tempitem.misc4 = 0;
8682 3261 tempitem.misc5 = 0;
8683 3261 tempitem.misc6 = 0;
8684 3261 tempitem.misc7 = 0;
8685 3261 tempitem.misc8 = 0;
8686 3261 tempitem.misc9 = 0;
8687 3261 tempitem.misc10 = 0;
8688 3261 tempitem.wpn = 0;
8689 3261 tempitem.wpn2 = 0;
8690 3261 tempitem.wpn3 = 0;
8691 3261 tempitem.wpn4 = 0;
8692 3261 tempitem.wpn5 = 0;
8693 3261 tempitem.wpn6 = 0;
8694 3261 tempitem.wpn7 = 0;
8695 3261 tempitem.wpn8 = 0;
8696 3261 tempitem.wpn9 = 0;
8697 3261 tempitem.wpn10 = 0;
8698 3261 break;
8699 }
8700 case itype_fairy:
8701 {
8702 545 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8703 545 tempitem.misc4 = 0;
8704 545 tempitem.misc5 = 0;
8705 545 tempitem.misc6 = 0;
8706 545 tempitem.misc7 = 0;
8707 545 tempitem.misc8 = 0;
8708 545 tempitem.misc9 = 0;
8709 545 tempitem.misc10 = 0;
8710 545 tempitem.wpn = 0;
8711 545 tempitem.wpn2 = 0;
8712 545 tempitem.wpn3 = 0;
8713 545 tempitem.wpn4 = 0;
8714 545 tempitem.wpn5 = 0;
8715 545 tempitem.wpn6 = 0;
8716 545 tempitem.wpn7 = 0;
8717 545 tempitem.wpn8 = 0;
8718 545 tempitem.wpn9 = 0;
8719 545 tempitem.wpn10 = 0;
8720 545 break;
8721 }
8722 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8723 {
8724 2872 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8725 2872 tempitem.misc1 = 0;
8726 2872 tempitem.misc2 = 0;
8727 2872 tempitem.misc3 = 0;
8728 2872 tempitem.misc4 = 0;
8729 2872 tempitem.misc5 = 0;
8730 2872 tempitem.misc6 = 0;
8731 2872 tempitem.misc7 = 0;
8732 2872 tempitem.misc8 = 0;
8733 2872 tempitem.misc9 = 0;
8734 2872 tempitem.misc10 = 0;
8735 2872 tempitem.wpn = 0;
8736 2872 tempitem.wpn2 = 0;
8737 2872 tempitem.wpn3 = 0;
8738 2872 tempitem.wpn4 = 0;
8739 2872 tempitem.wpn5 = 0;
8740 2872 tempitem.wpn6 = 0;
8741 2872 tempitem.wpn7 = 0;
8742 2872 tempitem.wpn8 = 0;
8743 2872 tempitem.wpn9 = 0;
8744 2872 tempitem.wpn10 = 0;
8745 2872 break;
8746 }
8747 case itype_bombbag:
8748 {
8749 1116 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8750 1116 tempitem.misc3 = 0;
8751 1116 tempitem.misc4 = 0;
8752 1116 tempitem.misc5 = 0;
8753 1116 tempitem.misc6 = 0;
8754 1116 tempitem.misc7 = 0;
8755 1116 tempitem.misc8 = 0;
8756 1116 tempitem.misc9 = 0;
8757 1116 tempitem.misc10 = 0;
8758 1116 tempitem.wpn = 0;
8759 1116 tempitem.wpn2 = 0;
8760 1116 tempitem.wpn3 = 0;
8761 1116 tempitem.wpn4 = 0;
8762 1116 tempitem.wpn5 = 0;
8763 1116 tempitem.wpn6 = 0;
8764 1116 tempitem.wpn7 = 0;
8765 1116 tempitem.wpn8 = 0;
8766 1116 tempitem.wpn9 = 0;
8767 1116 tempitem.wpn10 = 0;
8768 1116 break;
8769 }
8770 case itype_rocs:
8771 {
8772 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8773 279 tempitem.misc1 = 0;
8774 279 tempitem.misc2 = 0;
8775 279 tempitem.misc3 = 0;
8776 279 tempitem.misc4 = 0;
8777 279 tempitem.misc5 = 0;
8778 279 tempitem.misc6 = 0;
8779 279 tempitem.misc7 = 0;
8780 279 tempitem.misc8 = 0;
8781 279 tempitem.misc9 = 0;
8782 279 tempitem.misc10 = 0;
8783 279 tempitem.wpn = 0;
8784 279 tempitem.wpn2 = 0;
8785 279 tempitem.wpn3 = 0;
8786 279 tempitem.wpn4 = 0;
8787 279 tempitem.wpn5 = 0;
8788 279 tempitem.wpn6 = 0;
8789 279 tempitem.wpn7 = 0;
8790 279 tempitem.wpn8 = 0;
8791 279 tempitem.wpn9 = 0;
8792 279 tempitem.wpn10 = 0;
8793 279 break;
8794 }
8795 case itype_hoverboots:
8796 {
8797 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8798 279 tempitem.misc2 = 0;
8799 279 tempitem.misc3 = 0;
8800 279 tempitem.misc4 = 0;
8801 279 tempitem.misc5 = 0;
8802 279 tempitem.misc6 = 0;
8803 279 tempitem.misc7 = 0;
8804 279 tempitem.misc8 = 0;
8805 279 tempitem.misc9 = 0;
8806 279 tempitem.misc10 = 0;
8807 279 tempitem.wpn2 = 0;
8808 279 tempitem.wpn3 = 0;
8809 279 tempitem.wpn4 = 0;
8810 279 tempitem.wpn5 = 0;
8811 279 tempitem.wpn6 = 0;
8812 279 tempitem.wpn7 = 0;
8813 279 tempitem.wpn8 = 0;
8814 279 tempitem.wpn9 = 0;
8815 279 tempitem.wpn10 = 0;
8816 279 break;
8817 }
8818 case itype_spinscroll:
8819 {
8820 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8821 279 tempitem.misc2 = 0;
8822 279 tempitem.misc3 = 0;
8823 279 tempitem.misc4 = 0;
8824 279 tempitem.misc5 = 0;
8825 279 tempitem.misc6 = 0;
8826 279 tempitem.misc7 = 0;
8827 279 tempitem.misc8 = 0;
8828 279 tempitem.misc9 = 0;
8829 279 tempitem.misc10 = 0;
8830 279 tempitem.wpn = 0;
8831 279 tempitem.wpn2 = 0;
8832 279 tempitem.wpn3 = 0;
8833 279 tempitem.wpn4 = 0;
8834 279 tempitem.wpn5 = 0;
8835 279 tempitem.wpn6 = 0;
8836 279 tempitem.wpn7 = 0;
8837 279 tempitem.wpn8 = 0;
8838 279 tempitem.wpn9 = 0;
8839 279 tempitem.wpn10 = 0;
8840 279 break;
8841 }
8842 case itype_crossscroll:
8843 {
8844 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8845 279 tempitem.misc1 = 0;
8846 279 tempitem.misc2 = 0;
8847 279 tempitem.misc3 = 0;
8848 279 tempitem.misc4 = 0;
8849 279 tempitem.misc5 = 0;
8850 279 tempitem.misc6 = 0;
8851 279 tempitem.misc7 = 0;
8852 279 tempitem.misc8 = 0;
8853 279 tempitem.misc9 = 0;
8854 279 tempitem.misc10 = 0;
8855 279 tempitem.wpn = 0;
8856 279 tempitem.wpn2 = 0;
8857 279 tempitem.wpn3 = 0;
8858 279 tempitem.wpn4 = 0;
8859 279 tempitem.wpn5 = 0;
8860 279 tempitem.wpn6 = 0;
8861 279 tempitem.wpn7 = 0;
8862 279 tempitem.wpn8 = 0;
8863 279 tempitem.wpn9 = 0;
8864 279 tempitem.wpn10 = 0;
8865 279 break;
8866 }
8867 case itype_quakescroll:
8868 {
8869 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8870 279 tempitem.misc3 = 0;
8871 279 tempitem.misc4 = 0;
8872 279 tempitem.misc5 = 0;
8873 279 tempitem.misc6 = 0;
8874 279 tempitem.misc7 = 0;
8875 279 tempitem.misc8 = 0;
8876 279 tempitem.misc9 = 0;
8877 279 tempitem.misc10 = 0;
8878 279 tempitem.wpn = 0;
8879 279 tempitem.wpn2 = 0;
8880 279 tempitem.wpn3 = 0;
8881 279 tempitem.wpn4 = 0;
8882 279 tempitem.wpn5 = 0;
8883 279 tempitem.wpn6 = 0;
8884 279 tempitem.wpn7 = 0;
8885 279 tempitem.wpn8 = 0;
8886 279 tempitem.wpn9 = 0;
8887 279 tempitem.wpn10 = 0;
8888 279 break;
8889 }
8890 case itype_whispring:
8891 {
8892 561 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8893 561 tempitem.misc2 = 0;
8894 561 tempitem.misc3 = 0;
8895 561 tempitem.misc4 = 0;
8896 561 tempitem.misc5 = 0;
8897 561 tempitem.misc6 = 0;
8898 561 tempitem.misc7 = 0;
8899 561 tempitem.misc8 = 0;
8900 561 tempitem.misc9 = 0;
8901 561 tempitem.misc10 = 0;
8902 561 tempitem.wpn = 0;
8903 561 tempitem.wpn2 = 0;
8904 561 tempitem.wpn3 = 0;
8905 561 tempitem.wpn4 = 0;
8906 561 tempitem.wpn5 = 0;
8907 561 tempitem.wpn6 = 0;
8908 561 tempitem.wpn7 = 0;
8909 561 tempitem.wpn8 = 0;
8910 561 tempitem.wpn9 = 0;
8911 561 tempitem.wpn10 = 0;
8912 561 break;
8913 }
8914 case itype_chargering:
8915 {
8916 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8917 558 tempitem.misc3 = 0;
8918 558 tempitem.misc4 = 0;
8919 558 tempitem.misc5 = 0;
8920 558 tempitem.misc6 = 0;
8921 558 tempitem.misc7 = 0;
8922 558 tempitem.misc8 = 0;
8923 558 tempitem.misc9 = 0;
8924 558 tempitem.misc10 = 0;
8925 558 tempitem.wpn = 0;
8926 558 tempitem.wpn2 = 0;
8927 558 tempitem.wpn3 = 0;
8928 558 tempitem.wpn4 = 0;
8929 558 tempitem.wpn5 = 0;
8930 558 tempitem.wpn6 = 0;
8931 558 tempitem.wpn7 = 0;
8932 558 tempitem.wpn8 = 0;
8933 558 tempitem.wpn9 = 0;
8934 558 tempitem.wpn10 = 0;
8935 558 break;
8936 }
8937 case itype_perilscroll:
8938 {
8939 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8940 279 tempitem.misc2 = 0;
8941 279 tempitem.misc3 = 0;
8942 279 tempitem.misc4 = 0;
8943 279 tempitem.misc5 = 0;
8944 279 tempitem.misc6 = 0;
8945 279 tempitem.misc7 = 0;
8946 279 tempitem.misc8 = 0;
8947 279 tempitem.misc9 = 0;
8948 279 tempitem.misc10 = 0;
8949 279 tempitem.wpn = 0;
8950 279 tempitem.wpn2 = 0;
8951 279 tempitem.wpn3 = 0;
8952 279 tempitem.wpn4 = 0;
8953 279 tempitem.wpn5 = 0;
8954 279 tempitem.wpn6 = 0;
8955 279 tempitem.wpn7 = 0;
8956 279 tempitem.wpn8 = 0;
8957 279 tempitem.wpn9 = 0;
8958 279 tempitem.wpn10 = 0;
8959 279 break;
8960 }
8961 case itype_wealthmedal:
8962 {
8963 840 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8964 840 tempitem.misc2 = 0;
8965 840 tempitem.misc3 = 0;
8966 840 tempitem.misc4 = 0;
8967 840 tempitem.misc5 = 0;
8968 840 tempitem.misc6 = 0;
8969 840 tempitem.misc7 = 0;
8970 840 tempitem.misc8 = 0;
8971 840 tempitem.misc9 = 0;
8972 840 tempitem.misc10 = 0;
8973 840 tempitem.wpn = 0;
8974 840 tempitem.wpn2 = 0;
8975 840 tempitem.wpn3 = 0;
8976 840 tempitem.wpn4 = 0;
8977 840 tempitem.wpn5 = 0;
8978 840 tempitem.wpn6 = 0;
8979 840 tempitem.wpn7 = 0;
8980 840 tempitem.wpn8 = 0;
8981 840 tempitem.wpn9 = 0;
8982 840 tempitem.wpn10 = 0;
8983 840 break;
8984 }
8985 case itype_heartring:
8986 {
8987 843 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8988 843 tempitem.misc3 = 0;
8989 843 tempitem.misc4 = 0;
8990 843 tempitem.misc5 = 0;
8991 843 tempitem.misc6 = 0;
8992 843 tempitem.misc7 = 0;
8993 843 tempitem.misc8 = 0;
8994 843 tempitem.misc9 = 0;
8995 843 tempitem.misc10 = 0;
8996 843 tempitem.wpn = 0;
8997 843 tempitem.wpn2 = 0;
8998 843 tempitem.wpn3 = 0;
8999 843 tempitem.wpn4 = 0;
9000 843 tempitem.wpn5 = 0;
9001 843 tempitem.wpn6 = 0;
9002 843 tempitem.wpn7 = 0;
9003 843 tempitem.wpn8 = 0;
9004 843 tempitem.wpn9 = 0;
9005 843 tempitem.wpn10 = 0;
9006 843 break;
9007 }
9008 case itype_magicring:
9009 {
9010 1128 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9011 1128 tempitem.misc3 = 0;
9012 1128 tempitem.misc4 = 0;
9013 1128 tempitem.misc5 = 0;
9014 1128 tempitem.misc6 = 0;
9015 1128 tempitem.misc7 = 0;
9016 1128 tempitem.misc8 = 0;
9017 1128 tempitem.misc9 = 0;
9018 1128 tempitem.misc10 = 0;
9019 1128 tempitem.wpn = 0;
9020 1128 tempitem.wpn2 = 0;
9021 1128 tempitem.wpn3 = 0;
9022 1128 tempitem.wpn4 = 0;
9023 1128 tempitem.wpn5 = 0;
9024 1128 tempitem.wpn6 = 0;
9025 1128 tempitem.wpn7 = 0;
9026 1128 tempitem.wpn8 = 0;
9027 1128 tempitem.wpn9 = 0;
9028 1128 tempitem.wpn10 = 0;
9029 1128 break;
9030 }
9031 case itype_spinscroll2:
9032 {
9033 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9034 279 tempitem.misc2 = 0;
9035 279 tempitem.misc3 = 0;
9036 279 tempitem.misc4 = 0;
9037 279 tempitem.misc5 = 0;
9038 279 tempitem.misc6 = 0;
9039 279 tempitem.misc7 = 0;
9040 279 tempitem.misc8 = 0;
9041 279 tempitem.misc9 = 0;
9042 279 tempitem.misc10 = 0;
9043 279 tempitem.wpn = 0;
9044 279 tempitem.wpn2 = 0;
9045 279 tempitem.wpn3 = 0;
9046 279 tempitem.wpn4 = 0;
9047 279 tempitem.wpn5 = 0;
9048 279 tempitem.wpn6 = 0;
9049 279 tempitem.wpn7 = 0;
9050 279 tempitem.wpn8 = 0;
9051 279 tempitem.wpn9 = 0;
9052 279 tempitem.wpn10 = 0;
9053 279 break;
9054 }
9055 case itype_quakescroll2:
9056 {
9057 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9058 279 tempitem.misc3 = 0;
9059 279 tempitem.misc4 = 0;
9060 279 tempitem.misc5 = 0;
9061 279 tempitem.misc6 = 0;
9062 279 tempitem.misc7 = 0;
9063 279 tempitem.misc8 = 0;
9064 279 tempitem.misc9 = 0;
9065 279 tempitem.misc10 = 0;
9066 279 tempitem.wpn = 0;
9067 279 tempitem.wpn2 = 0;
9068 279 tempitem.wpn3 = 0;
9069 279 tempitem.wpn4 = 0;
9070 279 tempitem.wpn5 = 0;
9071 279 tempitem.wpn6 = 0;
9072 279 tempitem.wpn7 = 0;
9073 279 tempitem.wpn8 = 0;
9074 279 tempitem.wpn9 = 0;
9075 279 tempitem.wpn10 = 0;
9076 279 break;
9077 }
9078 case itype_agony:
9079 {
9080 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9081 279 tempitem.misc2 = 0;
9082 279 tempitem.misc3 = 0;
9083 279 tempitem.misc4 = 0;
9084 279 tempitem.misc5 = 0;
9085 279 tempitem.misc6 = 0;
9086 279 tempitem.misc7 = 0;
9087 279 tempitem.misc8 = 0;
9088 279 tempitem.misc9 = 0;
9089 279 tempitem.misc10 = 0;
9090 279 tempitem.wpn = 0;
9091 279 tempitem.wpn2 = 0;
9092 279 tempitem.wpn3 = 0;
9093 279 tempitem.wpn4 = 0;
9094 279 tempitem.wpn5 = 0;
9095 279 tempitem.wpn6 = 0;
9096 279 tempitem.wpn7 = 0;
9097 279 tempitem.wpn8 = 0;
9098 279 tempitem.wpn9 = 0;
9099 279 tempitem.wpn10 = 0;
9100 279 break;
9101 }
9102 case itype_stompboots:
9103 {
9104 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9105 279 tempitem.misc1 = 0;
9106 279 tempitem.misc2 = 0;
9107 279 tempitem.misc3 = 0;
9108 279 tempitem.misc4 = 0;
9109 279 tempitem.misc5 = 0;
9110 279 tempitem.misc6 = 0;
9111 279 tempitem.misc7 = 0;
9112 279 tempitem.misc8 = 0;
9113 279 tempitem.misc9 = 0;
9114 279 tempitem.misc10 = 0;
9115 279 tempitem.wpn = 0;
9116 279 tempitem.wpn2 = 0;
9117 279 tempitem.wpn3 = 0;
9118 279 tempitem.wpn4 = 0;
9119 279 tempitem.wpn5 = 0;
9120 279 tempitem.wpn6 = 0;
9121 279 tempitem.wpn7 = 0;
9122 279 tempitem.wpn8 = 0;
9123 279 tempitem.wpn9 = 0;
9124 279 tempitem.wpn10 = 0;
9125 279 break;
9126 }
9127 case itype_whimsicalring:
9128 {
9129 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9130 279 tempitem.misc2 = 0;
9131 279 tempitem.misc3 = 0;
9132 279 tempitem.misc4 = 0;
9133 279 tempitem.misc5 = 0;
9134 279 tempitem.misc6 = 0;
9135 279 tempitem.misc7 = 0;
9136 279 tempitem.misc8 = 0;
9137 279 tempitem.misc9 = 0;
9138 279 tempitem.misc10 = 0;
9139 279 tempitem.wpn = 0;
9140 279 tempitem.wpn2 = 0;
9141 279 tempitem.wpn3 = 0;
9142 279 tempitem.wpn4 = 0;
9143 279 tempitem.wpn5 = 0;
9144 279 tempitem.wpn6 = 0;
9145 279 tempitem.wpn7 = 0;
9146 279 tempitem.wpn8 = 0;
9147 279 tempitem.wpn9 = 0;
9148 279 tempitem.wpn10 = 0;
9149 279 break;
9150 }
9151 case itype_perilring:
9152 {
9153 306 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9154 306 tempitem.misc2 = 0;
9155 306 tempitem.misc3 = 0;
9156 306 tempitem.misc4 = 0;
9157 306 tempitem.misc5 = 0;
9158 306 tempitem.misc6 = 0;
9159 306 tempitem.misc7 = 0;
9160 306 tempitem.misc8 = 0;
9161 306 tempitem.misc9 = 0;
9162 306 tempitem.misc10 = 0;
9163 306 tempitem.wpn = 0;
9164 306 tempitem.wpn2 = 0;
9165 306 tempitem.wpn3 = 0;
9166 306 tempitem.wpn4 = 0;
9167 306 tempitem.wpn5 = 0;
9168 306 tempitem.wpn6 = 0;
9169 306 tempitem.wpn7 = 0;
9170 306 tempitem.wpn8 = 0;
9171 306 tempitem.wpn9 = 0;
9172 306 tempitem.wpn10 = 0;
9173 306 break;
9174 }
9175 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9176 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9177 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9178 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9179 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9180 {
9181 10652 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9182 10652 tempitem.misc1 = 0;
9183 10652 tempitem.misc2 = 0;
9184 10652 tempitem.misc3 = 0;
9185 10652 tempitem.misc4 = 0;
9186 10652 tempitem.misc5 = 0;
9187 10652 tempitem.misc6 = 0;
9188 10652 tempitem.misc7 = 0;
9189 10652 tempitem.misc8 = 0;
9190 10652 tempitem.misc9 = 0;
9191 10652 tempitem.misc10 = 0;
9192 10652 tempitem.wpn = 0;
9193 10652 tempitem.wpn2 = 0;
9194 10652 tempitem.wpn3 = 0;
9195 10652 tempitem.wpn4 = 0;
9196 10652 tempitem.wpn5 = 0;
9197 10652 tempitem.wpn6 = 0;
9198 10652 tempitem.wpn7 = 0;
9199 10652 tempitem.wpn8 = 0;
9200 10652 tempitem.wpn9 = 0;
9201 10652 tempitem.wpn10 = 0;
9202 10652 break;
9203 }
9204 }
9205 72192 }
9206 //Port quest rules to items
9207
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version <= 31)
9208 {
9209
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 71897 times.
72192 if(tempitem.type == itype_bomb)
9210 {
9211
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 139 times.
295 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9212 139 else tempitem.flags &= ~ item_flag2;
9213 295 }
9214
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 71616 times.
71897 else if(tempitem.type == itype_sbomb)
9215 {
9216
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 123 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9217 123 else tempitem.flags &= ~ item_flag2;
9218 281 }
9219
9220
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 70772 times.
71616 else if(tempitem.type == itype_brang)
9221 {
9222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9223 844 else tempitem.flags &= ~ item_flag4;
9224 844 }
9225
2/2
✓ Branch 0 taken 70475 times.
✓ Branch 1 taken 297 times.
70772 else if(tempitem.type == itype_wand)
9226 {
9227
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9228 279 else tempitem.flags &= ~ item_flag3;
9229 297 }
9230 72192 }
9231
9232 //Port quest rules to items
9233
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version <= 37)
9234 {
9235
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71910 times.
72192 if(tempitem.type == itype_flippers)
9236 {
9237
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 203 times.
282 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9238 203 else tempitem.flags &= ~ item_flag1;
9239 282 }
9240
2/2
✓ Branch 0 taken 54363 times.
✓ Branch 1 taken 17547 times.
71910 else if(tempitem.type == itype_sword)
9241 {
9242
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 17109 times.
17547 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9243 17109 else tempitem.flags &= ~ item_flag5;
9244 17547 }
9245
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 54066 times.
54363 else if(tempitem.type == itype_wand)
9246 {
9247
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 288 times.
297 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9248 288 else tempitem.flags &= ~ item_flag5;
9249 297 }
9250
4/4
✓ Branch 0 taken 53771 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 600 times.
✓ Branch 3 taken 53171 times.
54066 else if(tempitem.type == itype_book || tempitem.type == itype_candle)
9251 {
9252 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9253
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 520 times.
895 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9254 520 else tempitem.flags &= ~ item_flag3;
9255 895 }
9256 72192 }
9257
9258
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 38)
9259 {
9260
4/4
✓ Branch 0 taken 71348 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 70788 times.
72192 if(tempitem.type == itype_brang || tempitem.type == itype_hookshot)
9261 {
9262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9263 1404 else tempitem.flags &= ~item_flag4;
9264
9265
2/2
✓ Branch 0 taken 673 times.
✓ Branch 1 taken 731 times.
1404 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9266 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9267 1404 }
9268
2/2
✓ Branch 0 taken 69957 times.
✓ Branch 1 taken 831 times.
70788 else if(tempitem.type == itype_arrow)
9269 {
9270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9271 831 else tempitem.flags &= ~item_flag4;
9272
9273
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 435 times.
831 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9274 435 else tempitem.flags |= item_flag2;
9275 831 }
9276 72192 }
9277
9278
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 39)
9279 {
9280
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 71618 times.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 71018 times.
72192 if(tempitem.type == itype_divinefire || tempitem.type == itype_book || tempitem.type == itype_candle)
9281 {
9282
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1158 times.
1174 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9283 1158 else tempitem.flags &= ~item_flag5;
9284 1174 }
9285
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 70404 times.
71018 else if(tempitem.type == itype_potion)
9286 {
9287
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 452 times.
614 if(get_qr(qr_NONBUBBLEMEDICINE))
9288 {
9289 162 tempitem.flags &= ~(item_flag3|item_flag4);
9290 162 }
9291 else
9292 {
9293 452 tempitem.flags |= item_flag3;
9294
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 333 times.
452 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9295 333 else tempitem.flags &= ~item_flag4;
9296 }
9297 614 }
9298
2/2
✓ Branch 0 taken 69846 times.
✓ Branch 1 taken 558 times.
70404 else if(tempitem.type == itype_triforcepiece)
9299 {
9300
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 474 times.
558 if(get_qr(qr_NONBUBBLETRIFORCE))
9301 {
9302 84 tempitem.flags |= item_flag3;
9303
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9304 28 else tempitem.flags &= ~item_flag4;
9305 84 }
9306 else
9307 {
9308 474 tempitem.flags &= ~(item_flag3|item_flag4);
9309 }
9310 558 }
9311 72192 }
9312
9313
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 40)
9314 {
9315
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 306 times.
✓ Branch 3 taken 70969 times.
72192 if(tempitem.type == itype_ring || tempitem.type == itype_perilring)
9316 {
9317
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 934 times.
1223 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9318 934 else tempitem.flags &= ~item_flag1;
9319 1223 }
9320
8/8
✓ Branch 0 taken 70369 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 52822 times.
✓ Branch 3 taken 17547 times.
✓ Branch 4 taken 52525 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 279 times.
✓ Branch 7 taken 52246 times.
70969 else if(tempitem.type == itype_candle || tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_cbyrna)
9321 {
9322
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18615 times.
18723 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9323 18615 else tempitem.flags &= ~item_flag8;
9324 18723 }
9325
6/6
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
✓ Branch 2 taken 54348 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 54066 times.
72192 if(tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_hammer)
9326 {
9327
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 18048 times.
18126 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9328 18048 else tempitem.flags &= ~item_flag7;
9329 18126 }
9330
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 279 times.
54066 else if(tempitem.type == itype_cbyrna)
9331 {
9332 279 tempitem.flags |= item_flag7;
9333 279 }
9334 72192 }
9335
9336
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 41 )
9337 {
9338
2/2
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
72192 if(tempitem.type == itype_sword)
9339 {
9340
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 17311 times.
17547 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9341 17311 else tempitem.flags &= ~item_flag9;
9342
9343
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17119 times.
17547 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9344 17119 else tempitem.flags &= ~item_flag10;
9345 17547 }
9346 72192 }
9347
9348
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 42 )
9349 {
9350
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 71895 times.
72192 if(tempitem.type == itype_wand)
9351 {
9352
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9353 279 else tempitem.flags &= ~item_flag3;
9354
9355 297 tempitem.flags &= ~item_flag6;
9356 297 }
9357
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71613 times.
71895 else if(tempitem.type == itype_hammer)
9358 {
9359 282 tempitem.flags &= ~item_flag3;
9360 282 }
9361
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 71334 times.
71613 else if(tempitem.type == itype_cbyrna)
9362 {
9363 279 tempitem.flags |= item_flag3;
9364
9365 279 tempitem.flags &= ~item_flag6;
9366 279 }
9367
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 17547 times.
71334 else if(tempitem.type == itype_sword)
9368 {
9369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17547 times.
17547 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9370 17547 else tempitem.flags &= ~item_flag6;
9371 17547 }
9372 72192 }
9373
9374
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 43 )
9375 {
9376
2/2
✓ Branch 0 taken 71865 times.
✓ Branch 1 taken 327 times.
72192 if(tempitem.type == itype_whistle)
9377 {
9378
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 317 times.
327 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9379 317 else tempitem.flags &= ~item_flag3;
9380 327 }
9381 72192 }
9382
9383
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 45 )
9384 {
9385
2/2
✓ Branch 0 taken 71910 times.
✓ Branch 1 taken 282 times.
72192 if(tempitem.type == itype_flippers)
9386 {
9387 282 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9388 282 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9389 282 }
9390 72192 }
9391
9392
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 46 )
9393 {
9394
2/2
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
72192 if(tempitem.type == itype_raft)
9395 {
9396 279 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9397 279 }
9398 72192 }
9399
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 34 ) //! set the default counter for older quests.
9400 {
9401
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 72076 times.
72192 if ( (tempitem.flags & item_rupee_magic) )
9402 {
9403 116 tempitem.cost_counter[0] = 1;
9404 116 }
9405 else
9406 {
9407
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 29580 times.
72076 if(get_qr(qr_ENABLEMAGIC))
9408 42496 tempitem.cost_counter[0] = 4;
9409 else
9410 {
9411 29580 tempitem.cost_amount[0] = 0;
9412 29580 tempitem.cost_counter[0] = -1;
9413 }
9414 }
9415 72192 }
9416
9417
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 35 ) //new Lens of Truth flags
9418 {
9419
2/2
✓ Branch 0 taken 71937 times.
✓ Branch 1 taken 255 times.
72192 if ( tempitem.type == itype_lens )
9420 {
9421
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 10 times.
255 if ( get_qr(qr_RAFTLENS) )
9422 {
9423 10 tempitem.flags |= item_flag4;
9424 10 }
9425
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 166 times.
255 if ( get_qr(qr_LENSHINTS) )
9426 {
9427 166 tempitem.flags |= item_flag1;
9428 166 }
9429
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 13 times.
255 if ( get_qr(qr_LENSSEESENEMIES) )
9430 {
9431 13 tempitem.flags |= item_flag5;
9432 13 }
9433 255 }
9434 72192 }
9435
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9436 {
9437
2/2
✓ Branch 0 taken 577536 times.
✓ Branch 1 taken 72192 times.
649728 for ( int32_t q = 0; q < 8; q++ )
9438 {
9439 577536 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9440 577536 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9441 577536 tempitem.sprite_initiald[q] = 0;
9442 577536 }
9443 72192 tempitem.sprite_script = 0;
9444 72192 }
9445
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9446 {
9447 72192 tempitem.pickupflag = 0;
9448 72192 }
9449
9450
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 51 )
9451 {
9452
2/2
✓ Branch 0 taken 71592 times.
✓ Branch 1 taken 600 times.
72192 if( tempitem.type == itype_candle )
9453 {
9454 600 tempitem.misc4 = 50; //Step speed
9455 600 }
9456 72192 }
9457
9458
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if( s_version < 52 )
9459 {
9460
2/2
✓ Branch 0 taken 71334 times.
✓ Branch 1 taken 858 times.
72192 if( tempitem.type == itype_shield )
9461 858 tempitem.flags |= item_flag1; //'Block Front' flag
9462 72192 }
9463
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 72192 times.
122880 if(s_version < 53)
9464 {
9465
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 70785 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 281 times.
72192 switch(tempitem.type)
9466 {
9467 case itype_arrow:
9468 831 tempitem.cost_counter[1] = crARROWS;
9469 831 tempitem.cost_amount[1] = 1;
9470 831 break;
9471 case itype_bomb:
9472 295 tempitem.cost_counter[1] = crBOMBS;
9473 295 tempitem.cost_amount[1] = 1;
9474 295 break;
9475 case itype_sbomb:
9476 281 tempitem.cost_counter[1] = crSBOMBS;
9477 281 tempitem.cost_amount[1] = 1;
9478 281 break;
9479 default:
9480 70785 tempitem.cost_counter[1] = crNONE;
9481 70785 tempitem.cost_amount[1] = 0;
9482 70785 }
9483 72192 tempitem.magiccosttimer[1] = 0;
9484 72192 }
9485
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 75008 times.
122880 if( s_version < 54 )
9486 {
9487
2/2
✓ Branch 0 taken 74713 times.
✓ Branch 1 taken 295 times.
75008 if( tempitem.type == itype_flippers )
9488 295 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9489 75008 }
9490
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 75008 times.
122880 if(s_version < 55)
9491 {
9492
3/3
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 73848 times.
75008 switch(tempitem.type)
9493 {
9494 case itype_spinscroll:
9495 case itype_quakescroll:
9496 580 tempitem.usesound2 = WAV_ZN1CHARGE;
9497 580 break;
9498 case itype_spinscroll2:
9499 case itype_quakescroll2:
9500 580 tempitem.usesound2 = WAV_ZN1CHARGE2;
9501 580 break;
9502 }
9503 75008 }
9504
2/2
✓ Branch 0 taken 47872 times.
✓ Branch 1 taken 75008 times.
122880 if(s_version < 56)
9505 {
9506
4/4
✓ Branch 0 taken 73786 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 306 times.
75008 switch(tempitem.type)
9507 {
9508 case itype_divinefire:
9509
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 11 times.
290 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9510
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9511 290 tempitem.flags |= item_flag11; //Divine Fire
9512 290 break;
9513 case itype_candle:
9514
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 314 times.
626 SETFLAG(tempitem.flags, item_flag9, tempitem.level > 1); //Strong Fire
9515 626 tempitem.flags &= ~item_flag10; //Magic Fire
9516 626 tempitem.flags &= ~item_flag11; //Divine Fire
9517 626 break;
9518 case itype_book:
9519 306 tempitem.flags |= item_flag9; //Strong Fire
9520 306 tempitem.flags |= item_flag10; //Magic Fire
9521 306 tempitem.flags &= ~item_flag11; //Divine Fire
9522 306 break;
9523 }
9524 75008 }
9525
2/2
✓ Branch 0 taken 34560 times.
✓ Branch 1 taken 88320 times.
122880 if (s_version < 61)
9526 {
9527
2/2
✓ Branch 0 taken 69510 times.
✓ Branch 1 taken 18810 times.
88320 switch (tempitem.type)
9528 {
9529 case itype_sword:
9530 18810 tempitem.usesound2 = WAV_BEAM;
9531 18810 break;
9532 }
9533 88320 }
9534
9535
9536
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 111892 times.
122880 if(tempitem.level==0) // Always do this
9537 10988 tempitem.level=1;
9538
9539 122880 itemsbuf[i] = tempitem;
9540 122880 }
9541
9542 480 return 0;
9543 481 }
9544
9545 static bool did_init_def_items = false;
9546 245626 void init_def_items()
9547 {
9548
2/2
✓ Branch 0 taken 245255 times.
✓ Branch 1 taken 371 times.
245626 if(did_init_def_items) return;
9549 371 did_init_def_items = true;
9550 371 default_items[3].cost_counter[1] = crBOMBS;
9551 371 default_items[13].cost_counter[1] = crARROWS;
9552 371 default_items[14].cost_counter[1] = crARROWS;
9553 371 default_items[48].cost_counter[1] = crSBOMBS;
9554 371 default_items[57].cost_counter[1] = crARROWS;
9555 245626 }
9556 245626 void reset_itembuf(itemdata *item, int32_t id)
9557 {
9558 245626 init_def_items();
9559
2/2
✓ Branch 0 taken 103169 times.
✓ Branch 1 taken 142457 times.
245626 if(id<iLast)
9560 {
9561 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9562 142457 word tile = item->tile;
9563 142457 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9564 142457 int32_t ltm = item->ltm;
9565
9566 142457 *item = default_items[id];
9567 142457 item->tile = tile;
9568 142457 item->misc_flags = miscs;
9569 142457 item->csets = cset;
9570 142457 item->frames = frames;
9571 142457 item->speed = speed;
9572 142457 item->delay = delay;
9573 142457 item->ltm = ltm;
9574 142457 }
9575 245626 }
9576
9577 101632 void reset_itemname(int32_t id)
9578 {
9579 101632 sprintf(item_string[id],"zz%03d",id);
9580
9581
2/2
✓ Branch 0 taken 44861 times.
✓ Branch 1 taken 56771 times.
101632 if(id < iLast)
9582 56771 strcpy(item_string[id],old_item_string[id]);
9583 101632 }
9584
9585 481 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9586 {
9587
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9588
9589 481 word weapons_to_read=MAXWPNS;
9590 int32_t dummy;
9591 byte padding;
9592 wpndata tempweapon;
9593 481 word s_version=0;
9594
9595
9596
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(Header->zelda_version < 0x186)
9597 {
9598 6 weapons_to_read=64;
9599 6 }
9600
9601
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 6 times.
481 if(Header->zelda_version < 0x185)
9602 {
9603 6 weapons_to_read=32;
9604 6 }
9605
9606
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 457 times.
481 if(Header->zelda_version > 0x192)
9607 {
9608 457 weapons_to_read=0;
9609
9610 //section version info
9611
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
9612 {
9613 return qe_invalid;
9614 }
9615
9616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (s_version > V_WEAPONS)
9617 return qe_version;
9618
9619 457 FFCore.quest_format[vWeaponSprites] = s_version;
9620
9621
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!read_deprecated_section_cversion(f))
9622 {
9623 return qe_invalid;
9624 }
9625
9626 //section size
9627
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
9628 {
9629 return qe_invalid;
9630 }
9631
9632 //finally... section data
9633
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&weapons_to_read,f))
9634 {
9635 return qe_invalid;
9636 }
9637
9638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (weapons_to_read > MAXWPNS)
9639 {
9640 return qe_invalid;
9641 }
9642 457 }
9643
9644
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 83 times.
481 if(s_version>2)
9645 {
9646
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i=0; i<weapons_to_read; i++)
9647 {
9648 char tempname[64];
9649
9650
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if(!pfread(tempname, 64, f))
9651 {
9652 return qe_invalid;
9653 }
9654
9655 101888 weapon_string[i][0] = '\0';
9656 101888 strncat(weapon_string[i], tempname, 64 - 1);
9657 101888 }
9658
9659
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version<4)
9660 {
9661 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9662 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9663 }
9664
9665
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version<5)
9666 {
9667 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9668 }
9669
9670 /*
9671 if (s_version<6)
9672 {
9673 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9674 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9675 }
9676 */
9677 398 }
9678
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9679 {
9680
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9681 20992 reset_weaponname(i);
9682 82 }
9683
9684
2/2
✓ Branch 0 taken 110700 times.
✓ Branch 1 taken 481 times.
111181 for(int32_t i=0; i<weapons_to_read; i++)
9685 {
9686 110700 word oldtile = 0;
9687
2/2
✓ Branch 0 taken 49408 times.
✓ Branch 1 taken 61292 times.
110700 if (s_version < 8)
9688 {
9689
1/2
✓ Branch 0 taken 61292 times.
✗ Branch 1 not taken.
61292 if (!p_igetw(&oldtile, f))
9690 return qe_invalid;
9691 61292 }
9692
9693
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.misc,f))
9694 {
9695 return qe_invalid;
9696 }
9697
9698
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.csets,f))
9699 {
9700 return qe_invalid;
9701 }
9702
9703
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.frames,f))
9704 {
9705 return qe_invalid;
9706 }
9707
9708
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.speed,f))
9709 {
9710 return qe_invalid;
9711 }
9712
9713
1/2
✓ Branch 0 taken 110700 times.
✗ Branch 1 not taken.
110700 if(!p_getc(&tempweapon.type,f))
9714 {
9715 return qe_invalid;
9716 }
9717
9718
2/2
✓ Branch 0 taken 60012 times.
✓ Branch 1 taken 50688 times.
110700 if ( s_version >= 7 )
9719 {
9720
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetw(&tempweapon.script,f))
9721 {
9722 return qe_invalid;
9723 }
9724
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if(!p_igetl(&tempweapon.tile,f))
9725 {
9726 return qe_invalid;
9727 }
9728 50688 }
9729
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 60012 times.
110700 if ( s_version < 7 )
9730 {
9731 60012 tempweapon.tile = oldtile;
9732 60012 }
9733
9734
2/2
✓ Branch 0 taken 105900 times.
✓ Branch 1 taken 4800 times.
110700 if(Header->zelda_version < 0x193)
9735 {
9736
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9737 {
9738 return qe_invalid;
9739 }
9740 4800 }
9741
9742
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 8812 times.
110700 if(s_version < 6)
9743 {
9744
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9745 {
9746 18 tempweapon.misc |= WF_BEHIND;
9747 18 }
9748 else
9749 8794 tempweapon.misc &= ~WF_BEHIND;
9750 8812 }
9751
9752
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 110444 times.
110700 if (!should_skip)
9753 110444 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9754 110700 }
9755
9756
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (should_skip)
9757 1 return 0;
9758
9759
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(s_version<2)
9760 {
9761 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9762 82 }
9763
9764
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(s_version<5)
9765 {
9766 82 wpnsbuf[iwQuarterHearts].tile=1;
9767 82 wpnsbuf[iwQuarterHearts].csets=1;
9768 82 }
9769
9770
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(Header->zelda_version < 0x176)
9771 {
9772 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9773 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9774 itemsbuf[iMisc1].clear();
9775 itemsbuf[iMisc2].clear();
9776 }
9777
9778
3/4
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
485 if((Header->zelda_version < 0x192)||
9779
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 457 times.
462 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9780 {
9781 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9782 18 }
9783
9784
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if((Header->zelda_version < 0x210))
9785 {
9786 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9787 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9788 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9789 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9790 23 }
9791
9792 480 return 0;
9793 481 }
9794
9795 221192 static void guy_update_firesfx(guydata& tempguy)
9796 {
9797 221192 tempguy.firesfx = 0;
9798
2/2
✓ Branch 0 taken 6415 times.
✓ Branch 1 taken 214777 times.
221192 if (tempguy.type == eeWIZZ)
9799 {
9800
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 971 times.
✓ Branch 2 taken 3920 times.
✓ Branch 3 taken 826 times.
✓ Branch 4 taken 698 times.
6415 switch (tempguy.attributes[1])
9801 {
9802 case 0: // normal weapon
9803 3920 tempguy.firesfx = WAV_WAND;
9804 3920 break;
9805 case 1: // 8 shots
9806
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 744 times.
826 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9807 else
9808 {
9809
3/8
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
744 switch (tempguy.weapon)
9810 {
9811 case ewFireTrail:
9812 case ewFlame:
9813 case ewFlame2Trail:
9814 case ewFlame2:
9815 640 tempguy.firesfx = WAV_FIRE;
9816 640 break;
9817 case ewWind:
9818 case ewMagic:
9819 88 tempguy.firesfx = WAV_WAND;
9820 88 break;
9821 case ewIce:
9822 tempguy.firesfx = WAV_ZN1ICE;
9823 break;
9824 case ewRock:
9825 tempguy.firesfx = WAV_ZN1ROCK;
9826 break;
9827 case ewFireball2:
9828 case ewFireball:
9829 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9830 16 break;
9831 case ewBrang:
9832 tempguy.firesfx = WAV_BRANG;
9833 break;
9834 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9835 tempguy.firesfx = WAV_BOMB;
9836 break;
9837 default:
9838 tempguy.firesfx = 0;
9839 break;
9840 }
9841 744 break;
9842 }
9843 case 2: // Summon
9844 1053 tempguy.firesfx = WAV_FIRE;
9845 1053 break;
9846 case 3: // Summon Layer
9847 698 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9848 698 break;
9849 }
9850 6415 }
9851 else
9852 {
9853
6/6
✓ Branch 0 taken 162157 times.
✓ Branch 1 taken 52620 times.
✓ Branch 2 taken 41824 times.
✓ Branch 3 taken 203981 times.
✓ Branch 4 taken 47224 times.
✓ Branch 5 taken 47220 times.
214777 if ((tempguy.type == eeWALK || tempguy.type == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9854 {
9855 94444 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9856 94444 }
9857 else
9858 {
9859
7/8
✓ Branch 0 taken 9591 times.
✓ Branch 1 taken 2351 times.
✓ Branch 2 taken 1796 times.
✓ Branch 3 taken 12791 times.
✓ Branch 4 taken 171241 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3951 times.
✓ Branch 7 taken 2260 times.
203981 switch (tempguy.weapon)
9860 {
9861 case ewFireTrail:
9862 case ewFlame:
9863 case ewFlame2Trail:
9864 case ewFlame2:
9865 9591 tempguy.firesfx = WAV_FIRE;
9866 9591 break;
9867 case ewWind:
9868 case ewMagic:
9869 1796 tempguy.firesfx = WAV_WAND;
9870 1796 break;
9871 case ewIce:
9872 tempguy.firesfx = WAV_ZN1ICE;
9873 break;
9874 case ewRock:
9875 3951 tempguy.firesfx = WAV_ZN1ROCK;
9876 3951 break;
9877 case ewFireball2:
9878 case ewFireball:
9879 12791 tempguy.firesfx = WAV_ZN1FIREBALL;
9880 12791 break;
9881 case ewBrang:
9882 2260 tempguy.firesfx = WAV_BRANG;
9883 2260 break;
9884 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9885 2351 tempguy.firesfx = WAV_BOMB;
9886 2351 break;
9887 default:
9888 171241 tempguy.firesfx = 0;
9889 171241 break;
9890 }
9891 }
9892 }
9893 210400 }
9894
9895 210400 static void guy_update_weaponflags(guydata& tempguy)
9896 {
9897 210400 tempguy.weap_data.unblockable = 0;
9898 210400 tempguy.weap_data.moveflags = move_none;
9899
4/4
✓ Branch 0 taken 203892 times.
✓ Branch 1 taken 6508 times.
✓ Branch 2 taken 2996 times.
✓ Branch 3 taken 200896 times.
210400 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9900 9504 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
9901 210400 tempguy.weap_data.override_flags = 0;
9902 210400 tempguy.weap_data.hxofs = 0;
9903 210400 tempguy.weap_data.hyofs = 0;
9904 210400 tempguy.weap_data.hxsz = 0;
9905 210400 tempguy.weap_data.hysz = 0;
9906 210400 tempguy.weap_data.hzsz = 0;
9907 210400 tempguy.weap_data.xofs = 0;
9908 210400 tempguy.weap_data.yofs = 0;
9909 210400 tempguy.weap_data.tilew = 0;
9910 210400 tempguy.weap_data.tileh = 0;
9911
5/5
✓ Branch 0 taken 2500 times.
✓ Branch 1 taken 169270 times.
✓ Branch 2 taken 18463 times.
✓ Branch 3 taken 12807 times.
✓ Branch 4 taken 7360 times.
210400 switch (tempguy.weapon)
9912 {
9913 case ewFireball: case ewFireball2:
9914 12807 tempguy.weap_data.step = 1.75_zf;
9915 12807 break;
9916 case ewSword: case ewLitBomb: case ewLitSBomb:
9917 case ewRock: case ewMagic: case ewWind:
9918 18463 tempguy.weap_data.step = 3_zf;
9919 18463 break;
9920 case ewArrow:
9921 2500 tempguy.weap_data.step = 2_zf;
9922 2500 break;
9923 case ewFlame: case ewFlame2:
9924 7360 tempguy.weap_data.step = 1_zf;
9925 7360 break;
9926 default:
9927 169270 tempguy.weap_data.step = 0_zf;
9928 169270 break;
9929 }
9930
2/2
✓ Branch 0 taken 1052000 times.
✓ Branch 1 taken 210400 times.
1262400 for (int q = 0; q < WPNSPR_MAX; ++q)
9931 {
9932 1052000 tempguy.weap_data.burnsprs[q] = 0;
9933 1052000 tempguy.weap_data.light_rads[q] = 0;
9934 1052000 }
9935 210400 }
9936
9937 210400 static void guy_update_weaponspecialsfx(guydata& tempguy)
9938 {
9939
3/3
✓ Branch 0 taken 2260 times.
✓ Branch 1 taken 205734 times.
✓ Branch 2 taken 2406 times.
210400 switch (tempguy.weapon)
9940 {
9941 case ewBrang:
9942 2260 tempguy.specialsfx = WAV_BRANG;
9943 2260 break;
9944 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9945 2406 tempguy.specialsfx = WAV_BOMB;
9946 2406 break;
9947 default:
9948 205734 tempguy.specialsfx = 0;
9949 205734 break;
9950 }
9951 210400 }
9952
9953 480 void init_guys(int32_t guyversion)
9954 {
9955
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<MAXGUYS; i++)
9956 {
9957 245760 guysbuf[i] = default_guys[0];
9958 245760 }
9959
9960
2/2
✓ Branch 0 taken 84960 times.
✓ Branch 1 taken 480 times.
85440 for(int32_t i=0; i<OLDMAXGUYS; i++)
9961 {
9962 84960 guysbuf[i] = default_guys[i];
9963
2/2
✓ Branch 0 taken 84000 times.
✓ Branch 1 taken 960 times.
84960 guysbuf[i].spr_shadow = (guysbuf[i].type==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9964 84960 guysbuf[i].spr_death = iwDeath;
9965 84960 guysbuf[i].spr_spawn = iwSpawn;
9966 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9967
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 70446 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
84960 if(guyversion<=3 && i==ePATRABS)
9968 {
9969 82 guysbuf[i].bosspal=spDIG;
9970 82 guysbuf[i].cset=14;
9971 82 guysbuf[i].attributes[8] = 14;
9972 82 }
9973
9974
2/2
✓ Branch 0 taken 70446 times.
✓ Branch 1 taken 14514 times.
84960 if(guyversion<=3)
9975 {
9976 // Rope/Ghini Flash rules
9977
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9978 {
9979
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9980 {
9981 59 guysbuf[i].flags &= ~guy_flashing;
9982 59 }
9983 10443 }
9984
9985
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9986 {
9987
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9988 {
9989 72 guysbuf[i].flags &= ~guy_flashing;
9990 72 }
9991 2124 }
9992
9993
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9994 {
9995
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9996 {
9997 4 guysbuf[i].flags |= guy_blinking;
9998 4 }
9999
10000
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
10001 {
10002 38 guysbuf[i].flags |= guy_transparent;
10003 38 }
10004 82 }
10005
10006
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
10007 {
10008 164 guysbuf[i].flags |= guy_ignore_kill_all;
10009 164 }
10010 14514 }
10011
10012 // Darknut fix
10013
10/10
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 84000 times.
✓ Branch 3 taken 480 times.
✓ Branch 4 taken 83520 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 83040 times.
✓ Branch 7 taken 480 times.
✓ Branch 8 taken 480 times.
✓ Branch 9 taken 82560 times.
84960 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
10014 {
10015
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 410 times.
2400 if(get_qr(qr_NEWENEMYTILES))
10016 {
10017 1990 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
10018 1990 guysbuf[i].s_width=guysbuf[i].e_width;
10019 1990 guysbuf[i].s_height=guysbuf[i].e_height;
10020 1990 }
10021 410 else guysbuf[i].s_tile=860;
10022
10023
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2080 times.
2400 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
10024 2080 guysbuf[i].flags &= ~guy_bkshield;
10025 else
10026 320 guysbuf[i].flags |= guy_bkshield;
10027 2400 }
10028
10029
4/4
✓ Branch 0 taken 84480 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 84910 times.
✓ Branch 3 taken 50 times.
84960 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
10030 {
10031 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
10032 50 }
10033
10034 84960 guy_update_firesfx(guysbuf[i]);
10035 84960 guy_update_weaponflags(guysbuf[i]);
10036 84960 guy_update_weaponspecialsfx(guysbuf[i]);
10037 84960 }
10038 480 }
10039
10040 20992 void reset_weaponname(int32_t i)
10041 {
10042
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
10043 {
10044 7216 strcpy(weapon_string[i],old_weapon_string[i]);
10045 7216 }
10046 else
10047 13776 sprintf(weapon_string[i],"zz%03d",i);
10048 20992 }
10049
10050 480 void init_item_drop_sets()
10051 {
10052
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
10053 {
10054 // item_drop_sets[i] = default_item_drop_sets[0];
10055 122880 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10056 122880 }
10057
10058
2/2
✓ Branch 0 taken 6240 times.
✓ Branch 1 taken 480 times.
6720 for(int32_t i=0; i<isMAX; i++)
10059 {
10060 6240 item_drop_sets[i] = default_item_drop_sets[i];
10061
10062 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10063
2/2
✓ Branch 0 taken 62400 times.
✓ Branch 1 taken 6240 times.
68640 for(int32_t j=0; j<10; ++j)
10064 {
10065 62400 int32_t it = item_drop_sets[i].item[j];
10066
10067
3/4
✓ Branch 0 taken 43884 times.
✓ Branch 1 taken 18516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2832 times.
62400 if((itemsbuf[it].type == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10068
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 41052 times.
43884 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10069 {
10070 2832 item_drop_sets[i].chance[j+1]=0;
10071 2832 }
10072
4/4
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 57648 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1776 times.
59568 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10073 {
10074 144 item_drop_sets[i].chance[j+1]=0;
10075 144 }
10076
10077 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10078
2/2
✓ Branch 0 taken 62376 times.
✓ Branch 1 taken 24 times.
62400 if(itemsbuf[it].type == itype_misc)
10079 {
10080 // If a non-gameplay item was selected, then item drop was aborted.
10081 // Reflect this by increasing the 'Nothing' chance accordingly.
10082 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10083 24 item_drop_sets[i].chance[j+1]=0;
10084 24 }
10085 62400 }
10086 6240 }
10087 480 }
10088
10089 480 void init_favorites()
10090 {
10091
2/2
✓ Branch 0 taken 604800 times.
✓ Branch 1 taken 480 times.
605280 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10092 {
10093 604800 favorite_combos[i]=-1;
10094 604800 }
10095 480 }
10096
10097 767 int32_t init_combo_classes()
10098 {
10099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 767 times.
767 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10100
2/2
✓ Branch 0 taken 141128 times.
✓ Branch 1 taken 767 times.
141895 for(int32_t i=0; i<cMAX; i++)
10101 {
10102 141128 combo_class_buf[i] = default_combo_classes[i];
10103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 141128 times.
141128 if ( char const* nm = zi->getComboTypeName(i) )
10104 {
10105 141128 size_t len = strlen(nm);
10106
2/2
✓ Branch 0 taken 9032192 times.
✓ Branch 1 taken 141128 times.
9173320 for ( size_t q = 0; q < 64; q++ )
10107 {
10108
2/2
✓ Branch 0 taken 2068599 times.
✓ Branch 1 taken 6963593 times.
9032192 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10109 9032192 }
10110 141128 }
10111 141128 }
10112
10113 767 return 0;
10114 }
10115
10116 305 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10117 {
10118
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 259 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if (should_skip) return 0;
10120
10121
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 assert(v_herosprites < 6);
10122
10123 305 zinit.hero_swim_speed=67; //default
10124 305 setupherotiles(zinit.heroAnimationStyle);
10125 305 setupherodefenses();
10126 305 setupherooffsets();
10127
10128
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 200 times.
305 if(v_herosprites>=0)
10129 {
10130 word tile, tile2;
10131 byte flip, extend, dummy_byte;
10132
10133
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10134 {
10135
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10136 {
10137 return qe_invalid;
10138 }
10139
10140
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10141 {
10142 return qe_invalid;
10143 }
10144
10145
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10146 {
10147 return qe_invalid;
10148 }
10149
10150 800 walkspr[i][spr_tile]=(int32_t)tile;
10151 800 walkspr[i][spr_flip]=(int32_t)flip;
10152 800 walkspr[i][spr_extend]=(int32_t)extend;
10153 800 }
10154
10155
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10156 {
10157
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10158 {
10159 return qe_invalid;
10160 }
10161
10162
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10163 {
10164 return qe_invalid;
10165 }
10166
10167
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10168 {
10169 return qe_invalid;
10170 }
10171
10172 800 stabspr[i][spr_tile]=(int32_t)tile;
10173 800 stabspr[i][spr_flip]=(int32_t)flip;
10174 800 stabspr[i][spr_extend]=(int32_t)extend;
10175 800 }
10176
10177
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10178 {
10179
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10180 {
10181 return qe_invalid;
10182 }
10183
10184
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10185 {
10186 return qe_invalid;
10187 }
10188
10189
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10190 {
10191 return qe_invalid;
10192 }
10193
10194 800 slashspr[i][spr_tile]=(int32_t)tile;
10195 800 slashspr[i][spr_flip]=(int32_t)flip;
10196 800 slashspr[i][spr_extend]=(int32_t)extend;
10197 800 }
10198
10199
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10200 {
10201
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10202 {
10203 return qe_invalid;
10204 }
10205
10206
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10207 {
10208 return qe_invalid;
10209 }
10210
10211
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10212 {
10213 return qe_invalid;
10214 }
10215
10216 800 floatspr[i][spr_tile]=(int32_t)tile;
10217 800 floatspr[i][spr_flip]=(int32_t)flip;
10218 800 floatspr[i][spr_extend]=(int32_t)extend;
10219 800 }
10220
10221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>1)
10222 {
10223
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10224 {
10225
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10226 {
10227 return qe_invalid;
10228 }
10229
10230
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10231 {
10232 return qe_invalid;
10233 }
10234
10235
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10236 {
10237 return qe_invalid;
10238 }
10239
10240 800 swimspr[i][spr_tile]=(int32_t)tile;
10241 800 swimspr[i][spr_flip]=(int32_t)flip;
10242 800 swimspr[i][spr_extend]=(int32_t)extend;
10243 800 }
10244 200 }
10245
10246
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10247 {
10248
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10249 {
10250 return qe_invalid;
10251 }
10252
10253
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10254 {
10255 return qe_invalid;
10256 }
10257
10258
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10259 {
10260 return qe_invalid;
10261 }
10262
10263 800 divespr[i][spr_tile]=(int32_t)tile;
10264 800 divespr[i][spr_flip]=(int32_t)flip;
10265 800 divespr[i][spr_extend]=(int32_t)extend;
10266 800 }
10267
10268
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10269 {
10270
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10271 {
10272 return qe_invalid;
10273 }
10274
10275
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10276 {
10277 return qe_invalid;
10278 }
10279
10280
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10281 {
10282 return qe_invalid;
10283 }
10284
10285 800 poundspr[i][spr_tile]=(int32_t)tile;
10286 800 poundspr[i][spr_flip]=(int32_t)flip;
10287 800 poundspr[i][spr_extend]=(int32_t)extend;
10288 800 }
10289
10290
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&tile,f))
10291 {
10292 return qe_invalid;
10293 }
10294
10295 200 flip=0;
10296
10297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>0)
10298 {
10299
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&flip,f))
10300 {
10301 return qe_invalid;
10302 }
10303 200 }
10304
10305
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&extend,f))
10306 {
10307 return qe_invalid;
10308 }
10309
10310 200 castingspr[spr_tile]=(int32_t)tile;
10311 200 castingspr[spr_flip]=(int32_t)flip;
10312 200 castingspr[spr_extend]=(int32_t)extend;
10313
10314
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(v_herosprites>0)
10315 {
10316 200 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10317
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
600 for(int32_t i=0; i<2; i++)
10318 {
10319
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 400 times.
1200 for(int32_t j=0; j<num_holdsprs; j++)
10320 {
10321
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10322 {
10323 return qe_invalid;
10324 }
10325
10326
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10327 {
10328 return qe_invalid;
10329 }
10330
10331
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10332 {
10333 return qe_invalid;
10334 }
10335
10336 800 holdspr[i][j][spr_tile]=(int32_t)tile;
10337 800 holdspr[i][j][spr_flip]=(int32_t)flip;
10338 800 holdspr[i][j][spr_extend]=(int32_t)extend;
10339 800 }
10340 400 }
10341 200 }
10342 else
10343 {
10344 for(int32_t i=0; i<2; i++)
10345 {
10346 if(!p_igetw(&tile,f))
10347 {
10348 return qe_invalid;
10349 }
10350
10351 if(!p_igetw(&tile2,f))
10352 {
10353 return qe_invalid;
10354 }
10355
10356 if(!p_getc(&extend,f))
10357 {
10358 return qe_invalid;
10359 }
10360
10361 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10362 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10363 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10364 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10365 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10366 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10367 }
10368 }
10369
10370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>2)
10371 {
10372
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10373 {
10374
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10375 {
10376 return qe_invalid;
10377 }
10378
10379
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10380 {
10381 return qe_invalid;
10382 }
10383
10384
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10385 {
10386 return qe_invalid;
10387 }
10388
10389 800 jumpspr[i][spr_tile]=(int32_t)tile;
10390 800 jumpspr[i][spr_flip]=(int32_t)flip;
10391 800 jumpspr[i][spr_extend]=(int32_t)extend;
10392 800 }
10393 200 }
10394
10395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>3)
10396 {
10397
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10398 {
10399
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10400 {
10401 return qe_invalid;
10402 }
10403
10404
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10405 {
10406 return qe_invalid;
10407 }
10408
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_getc(&extend,f))
10410 {
10411 return qe_invalid;
10412 }
10413
10414 800 chargespr[i][spr_tile]=(int32_t)tile;
10415 800 chargespr[i][spr_flip]=(int32_t)flip;
10416 800 chargespr[i][spr_extend]=(int32_t)extend;
10417 800 }
10418 200 }
10419
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>4)
10421 {
10422
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&dummy_byte,f))
10423 {
10424 return qe_invalid;
10425 }
10426
10427 200 zinit.hero_swim_speed=(byte)dummy_byte;
10428 200 }
10429
10430 200 memset(frozenspr, 0, sizeof(frozenspr));
10431 200 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10432 200 memset(onfirespr, 0, sizeof(onfirespr));
10433 200 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10434 200 memset(diggingspr, 0, sizeof(diggingspr));
10435 200 memset(usingrodspr, 0, sizeof(usingrodspr));
10436 200 memset(usingcanespr, 0, sizeof(usingcanespr));
10437 200 memset(pushingspr, 0, sizeof(pushingspr));
10438 200 memset(liftingspr, 0, sizeof(liftingspr));
10439 200 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10440 200 memset(stunnedspr, 0, sizeof(stunnedspr));
10441 200 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10442 200 memset(fallingspr, 0, sizeof(fallingspr));
10443 200 memset(shockedspr, 0, sizeof(shockedspr));
10444 200 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10445 200 memset(pullswordspr, 0, sizeof(pullswordspr));
10446 200 memset(readingspr, 0, sizeof(readingspr));
10447 200 memset(slash180spr, 0, sizeof(slash180spr));
10448 200 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10449 200 memset(dashspr, 0, sizeof(dashspr));
10450 200 memset(bonkspr, 0, sizeof(bonkspr));
10451 200 memset(medallionsprs, 0, sizeof(medallionsprs));
10452 200 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10453 200 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10454
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t q = 0; q < 4; ++q)
10455 {
10456
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 800 times.
3200 for(int32_t p = 0; p < 3; ++p)
10457 {
10458 2400 drowningspr[q][p] = divespr[q][p];
10459 2400 drowning_lavaspr[q][p] = divespr[q][p];
10460 2400 }
10461 800 }
10462 200 memset(sideswimspr, 0, sizeof(sideswimspr));
10463 200 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10464 200 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10465 200 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10466 200 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10467 200 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10468 200 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10469 200 }
10470
10471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if(FFCore.quest_format[vInitData] < 34)
10472 {
10473 305 bool fastswim = zinit.hero_swim_speed > 60;
10474 // '2/3' or '1/2'
10475 305 zinit.hero_swim_mult = fastswim ? 2 : 1;
10476 305 zinit.hero_swim_div = fastswim ? 3 : 2;
10477 305 }
10478 305 return 0;
10479 305 }
10480
10481 33660 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10482 {
10483 33660 arr[spr_tile] = tile;
10484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33660 times.
33660 arr[spr_flip] = (flip > 3 ? 0 : flip);
10485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33660 times.
33660 arr[spr_extend] = (ext > 2 ? 0 : ext);
10486 33660 }
10487 //Used to read the player sprites as int32_t, not word.
10488 198 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10489 {
10490 198 zinit.hero_swim_speed=67; //default
10491 198 setupherotiles(zinit.heroAnimationStyle);
10492 198 setupherodefenses();
10493 198 setupherooffsets();
10494
10495 int32_t tile, tile2;
10496 byte flip, extend, dummy_byte;
10497
10498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>=0)
10499 {
10500
10501
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10502 {
10503
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10504 {
10505 return qe_invalid;
10506 }
10507
10508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10514 {
10515 return qe_invalid;
10516 }
10517
10518 792 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10519 792 }
10520
10521
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10522 {
10523
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10524 {
10525 return qe_invalid;
10526 }
10527
10528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10529 {
10530 return qe_invalid;
10531 }
10532
10533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10534 {
10535 return qe_invalid;
10536 }
10537
10538 792 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10539 792 }
10540
10541
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10542 {
10543
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10544 {
10545 return qe_invalid;
10546 }
10547
10548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10549 {
10550 return qe_invalid;
10551 }
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10554 {
10555 return qe_invalid;
10556 }
10557
10558 792 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10559 792 }
10560
10561
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10562 {
10563
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10564 {
10565 return qe_invalid;
10566 }
10567
10568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10569 {
10570 return qe_invalid;
10571 }
10572
10573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10574 {
10575 return qe_invalid;
10576 }
10577
10578 792 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10579 792 }
10580
10581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>1)
10582 {
10583
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10584 {
10585
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10586 {
10587 return qe_invalid;
10588 }
10589
10590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10591 {
10592 return qe_invalid;
10593 }
10594
10595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10596 {
10597 return qe_invalid;
10598 }
10599
10600 792 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10601 792 }
10602 198 }
10603
10604
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10605 {
10606
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10607 {
10608 return qe_invalid;
10609 }
10610
10611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10612 {
10613 return qe_invalid;
10614 }
10615
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10617 {
10618 return qe_invalid;
10619 }
10620
10621 792 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10622 792 }
10623
10624
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10625 {
10626
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10637 {
10638 return qe_invalid;
10639 }
10640
10641 792 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10642 792 }
10643
10644
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&tile,f))
10645 {
10646 return qe_invalid;
10647 }
10648
10649 198 flip=0;
10650
10651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>0)
10652 {
10653
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&flip,f))
10654 {
10655 return qe_invalid;
10656 }
10657 198 }
10658
10659
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&extend,f))
10660 {
10661 return qe_invalid;
10662 }
10663
10664 198 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10665
10666
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(v_herosprites>0)
10667 {
10668 198 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10669
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 198 times.
594 for(int32_t i=0; i<2; i++)
10670 {
10671
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 396 times.
1584 for(int32_t j=0; j<num_holdsprs; j++)
10672 {
10673
1/2
✓ Branch 0 taken 1188 times.
✗ Branch 1 not taken.
1188 if(!p_igetl(&tile,f))
10674 {
10675 return qe_invalid;
10676 }
10677
10678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1188 times.
1188 if(!p_getc(&flip,f))
10679 {
10680 return qe_invalid;
10681 }
10682
10683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1188 times.
1188 if(!p_getc(&extend,f))
10684 {
10685 return qe_invalid;
10686 }
10687
10688 1188 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10689 1188 }
10690 396 }
10691 198 }
10692 else
10693 {
10694 for(int32_t i=0; i<2; i++)
10695 {
10696 if(!p_igetl(&tile,f))
10697 {
10698 return qe_invalid;
10699 }
10700
10701 if(!p_igetl(&tile2,f))
10702 {
10703 return qe_invalid;
10704 }
10705
10706 if(!p_getc(&extend,f))
10707 {
10708 return qe_invalid;
10709 }
10710
10711 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10712 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10713 }
10714 }
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>2)
10717 {
10718
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10719 {
10720
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10721 {
10722 return qe_invalid;
10723 }
10724
10725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10726 {
10727 return qe_invalid;
10728 }
10729
10730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10731 {
10732 return qe_invalid;
10733 }
10734
10735 792 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10736 792 }
10737 198 }
10738
10739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>3)
10740 {
10741
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
10742 {
10743
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10744 {
10745 return qe_invalid;
10746 }
10747
10748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10749 {
10750 return qe_invalid;
10751 }
10752
10753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10754 {
10755 return qe_invalid;
10756 }
10757
10758 792 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10759 792 }
10760 198 }
10761
10762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if(v_herosprites>4)
10763 {
10764
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&dummy_byte,f))
10765 {
10766 return qe_invalid;
10767 }
10768
10769 198 zinit.hero_swim_speed=(byte)dummy_byte;
10770 198 }
10771
10772
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(v_herosprites>6)
10773 {
10774
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10775 {
10776
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10777 return qe_invalid;
10778
10779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10780 return qe_invalid;
10781
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10783 return qe_invalid;
10784
10785 792 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10786 792 }
10787
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10788 {
10789
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10790 return qe_invalid;
10791
10792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10793 return qe_invalid;
10794
10795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10796 return qe_invalid;
10797
10798 792 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10799 792 }
10800
10801
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10802 {
10803
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10804 return qe_invalid;
10805
10806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10807 return qe_invalid;
10808
10809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10810 return qe_invalid;
10811
10812 792 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10813 792 }
10814
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10815 {
10816
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10817 return qe_invalid;
10818
10819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10820 return qe_invalid;
10821
10822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10823 return qe_invalid;
10824
10825 792 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10826 792 }
10827
10828
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10829 {
10830
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10831 return qe_invalid;
10832
10833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10834 return qe_invalid;
10835
10836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10837 return qe_invalid;
10838
10839 792 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10840 792 }
10841
10842
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10843 {
10844
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10845 return qe_invalid;
10846
10847
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10848 return qe_invalid;
10849
10850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10851 return qe_invalid;
10852
10853 792 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10854 792 }
10855
10856
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10857 {
10858
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10859 return qe_invalid;
10860
10861
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10862 return qe_invalid;
10863
10864
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10865 return qe_invalid;
10866
10867 792 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10868 792 }
10869
10870
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10871 {
10872
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10873 return qe_invalid;
10874
10875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
10876 return qe_invalid;
10877
10878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10879 return qe_invalid;
10880
10881 792 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10882 792 }
10883
10884
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10885 {
10886
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10887 return qe_invalid;
10888
10889
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10890 return qe_invalid;
10891
10892
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10893 return qe_invalid;
10894
10895 792 byte frames = 0;
10896
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 772 times.
792 if(v_herosprites > 15)
10897 {
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 772 times.
772 if(!p_getc(&frames,f))
10899 return qe_invalid;
10900 772 }
10901
10902 792 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10903 792 liftingspr[q][spr_frames] = frames;
10904 792 }
10905
10906
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10907 {
10908
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10915 return qe_invalid;
10916
10917 792 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10918 792 }
10919
10920
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10921 {
10922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&tile,f))
10923 return qe_invalid;
10924
10925
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10926 return qe_invalid;
10927
10928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10929 return qe_invalid;
10930
10931 792 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10932 792 }
10933
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10934 {
10935
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10936 return qe_invalid;
10937
10938
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10942 return qe_invalid;
10943
10944 792 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10945 792 }
10946
10947
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10948 {
10949
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10950 return qe_invalid;
10951
10952
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10953 return qe_invalid;
10954
10955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
10956 return qe_invalid;
10957
10958 792 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10959 792 }
10960
10961
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10962 {
10963
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10964 return qe_invalid;
10965
10966
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10967 return qe_invalid;
10968
10969
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10970 return qe_invalid;
10971
10972 792 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10973 792 }
10974
10975
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10976 {
10977
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10978 return qe_invalid;
10979
10980
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10981 return qe_invalid;
10982
10983
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10984 return qe_invalid;
10985
10986 792 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10987 792 }
10988
10989
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
10990 {
10991
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
10992 return qe_invalid;
10993
10994
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
10995 return qe_invalid;
10996
10997
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
10998 return qe_invalid;
10999
11000 792 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11001 792 }
11002
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11003 {
11004
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11005 return qe_invalid;
11006
11007
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11008 return qe_invalid;
11009
11010
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11011 return qe_invalid;
11012
11013 792 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11014 792 }
11015
11016
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11017 {
11018
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11019 return qe_invalid;
11020
11021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11022 return qe_invalid;
11023
11024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11025 return qe_invalid;
11026
11027 792 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11028 792 }
11029
11030
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11031 {
11032
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11033 return qe_invalid;
11034
11035
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11036 return qe_invalid;
11037
11038
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11039 return qe_invalid;
11040
11041 792 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11042 792 }
11043
11044
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11045 {
11046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&tile,f))
11047 return qe_invalid;
11048
11049
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11050 return qe_invalid;
11051
11052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11053 return qe_invalid;
11054
11055 792 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11056 792 }
11057
11058
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11059 {
11060
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11061 return qe_invalid;
11062
11063
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11064 return qe_invalid;
11065
11066
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11067 return qe_invalid;
11068
11069 792 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11070 792 }
11071
11072
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11073 {
11074
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11075 return qe_invalid;
11076
11077
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11078 return qe_invalid;
11079
11080
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11081 return qe_invalid;
11082
11083 792 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11084 792 }
11085
11086
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11087 {
11088
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11089 return qe_invalid;
11090
11091
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&flip,f))
11092 return qe_invalid;
11093
11094
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&extend,f))
11095 return qe_invalid;
11096
11097 792 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11098 792 }
11099
11100
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 198 times.
792 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11101 {
11102
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetl(&tile,f))
11103 return qe_invalid;
11104
11105
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_getc(&flip,f))
11106 return qe_invalid;
11107
11108
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_getc(&extend,f))
11109 return qe_invalid;
11110
11111 594 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11112 594 }
11113 198 }
11114 else
11115 {
11116 memset(frozenspr, 0, sizeof(frozenspr));
11117 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11118 memset(onfirespr, 0, sizeof(onfirespr));
11119 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11120 memset(diggingspr, 0, sizeof(diggingspr));
11121 memset(usingrodspr, 0, sizeof(usingrodspr));
11122 memset(usingcanespr, 0, sizeof(usingcanespr));
11123 memset(pushingspr, 0, sizeof(pushingspr));
11124 memset(liftingspr, 0, sizeof(liftingspr));
11125 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11126 memset(stunnedspr, 0, sizeof(stunnedspr));
11127 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11128 memset(fallingspr, 0, sizeof(fallingspr));
11129 memset(shockedspr, 0, sizeof(shockedspr));
11130 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11131 memset(pullswordspr, 0, sizeof(pullswordspr));
11132 memset(readingspr, 0, sizeof(readingspr));
11133 memset(slash180spr, 0, sizeof(slash180spr));
11134 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11135 memset(dashspr, 0, sizeof(dashspr));
11136 memset(bonkspr, 0, sizeof(bonkspr));
11137 memset(medallionsprs, 0, sizeof(medallionsprs));
11138 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11139 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11140 for(int32_t q = 0; q < 4; ++q)
11141 {
11142 for(int32_t p = 0; p < 3; ++p)
11143 {
11144 drowningspr[q][p] = divespr[q][p];
11145 drowning_lavaspr[q][p] = divespr[q][p];
11146 }
11147 }
11148 }
11149
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 8)
11150 {
11151
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11152 {
11153
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11154 return qe_invalid;
11155
11156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11157 return qe_invalid;
11158
11159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11160 return qe_invalid;
11161
11162 792 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11163 792 }
11164 198 }
11165 else
11166 {
11167 memset(sideswimspr, 0, sizeof(sideswimspr));
11168 }
11169
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 9)
11170 {
11171
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11172 {
11173
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11174 return qe_invalid;
11175
11176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11177 return qe_invalid;
11178
11179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11180 return qe_invalid;
11181
11182 792 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11183 792 }
11184
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11185 {
11186
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11187 return qe_invalid;
11188
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11190 return qe_invalid;
11191
11192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11193 return qe_invalid;
11194
11195 792 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11196 792 }
11197
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11198 {
11199
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11200 return qe_invalid;
11201
11202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11203 return qe_invalid;
11204
11205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11206 return qe_invalid;
11207
11208 792 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11209 792 }
11210
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11211 {
11212
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11213 return qe_invalid;
11214
11215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11216 return qe_invalid;
11217
11218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11219 return qe_invalid;
11220
11221 792 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11222 792 }
11223 198 }
11224 else
11225 {
11226 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11227 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11228 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11229 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11230 }
11231
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 10)
11232 {
11233
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11234 {
11235 int32_t hmr;
11236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetl(&hmr,f))
11237 return qe_invalid;
11238
11239 792 hammeroffsets[q] = hmr;
11240 792 }
11241 198 }
11242 else
11243 {
11244 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11245 }
11246
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 11)
11247 {
11248
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 198 times.
792 for(int32_t q = 0; q < 3; ++q)
11249 {
11250
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetl(&tile,f))
11251 return qe_invalid;
11252
11253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 if(!p_getc(&flip,f))
11254 return qe_invalid;
11255
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 if(!p_getc(&extend,f))
11257 return qe_invalid;
11258
11259 594 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11260 594 }
11261 198 }
11262 else
11263 {
11264 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11265 }
11266
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 12)
11267 {
11268
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&tile,f))
11269 return qe_invalid;
11270
11271
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&flip,f))
11272 return qe_invalid;
11273
11274
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&extend,f))
11275 return qe_invalid;
11276 198 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11277
11278 198 }
11279 else
11280 {
11281 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11282 }
11283
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 13)
11284 {
11285
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11286 {
11287
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11288 return qe_invalid;
11289
11290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11291 return qe_invalid;
11292
11293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11294 return qe_invalid;
11295
11296 792 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11297 792 }
11298 198 }
11299 else
11300 {
11301 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11302 }
11303
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 14)
11304 {
11305
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t q = 0; q < 4; ++q)
11306 {
11307
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_igetl(&tile,f))
11308 return qe_invalid;
11309
11310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&flip,f))
11311 return qe_invalid;
11312
11313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&extend,f))
11314 return qe_invalid;
11315
11316 792 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11317 792 }
11318 198 }
11319 else
11320 {
11321 memset(revslashspr, 0, sizeof(revslashspr));
11322 }
11323
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if (v_herosprites > 7)
11324 {
11325 198 int32_t num_defense = wMax;
11326 198 byte def = 0;
11327
11328 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11329 /*if(v_herosprites > [x])
11330 * {
11331 * num_defense = 146 //value of wMax on version 8
11332 * }
11333 */
11334
11335
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 198 times.
29106 for (int32_t q = 0; q < num_defense; q++)
11336 {
11337
1/2
✓ Branch 0 taken 28908 times.
✗ Branch 1 not taken.
28908 if (!p_getc(&def, f))
11338 return qe_invalid;
11339
11340 28908 hero_defenses[q] = def;
11341 28908 }
11342 198 }
11343 else
11344 {
11345 int32_t num_defense = wMax;
11346 for (int32_t q = 0; q < num_defense; q++)
11347 {
11348 hero_defenses[q] = 0;
11349 }
11350 }
11351 198 }
11352
11353
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 11 times.
198 if(FFCore.quest_format[vInitData] < 34)
11354 {
11355 11 bool fastswim = zinit.hero_swim_speed > 60;
11356 // '2/3' or '1/2'
11357 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11358 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11359 11 }
11360 198 return 0;
11361 198 }
11362
11363
11364 398 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11365 {
11366 //these are here to bypass compiler warnings about unused arguments
11367 398 Header=Header;
11368
11369 dword dummy;
11370 398 word s_version=0;
11371
11372 //section version info
11373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
11374 {
11375 return qe_invalid;
11376 }
11377
11378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_HEROSPRITES)
11379 return qe_version;
11380
11381 398 FFCore.quest_format[vHeroSprites] = s_version;
11382
11383
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
11384 {
11385 return qe_invalid;
11386 }
11387
11388 //section size
11389
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
11390 {
11391 return qe_invalid;
11392 }
11393
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if ( s_version >= 6 )
11394 {
11395 198 return readherosprites3(f, s_version);
11396 }
11397 200 else return readherosprites2(f, s_version);
11398 398 }
11399
11400 217 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11401 {
11402 217 subscreens_active.clear();
11403 217 subscreens_passive.clear();
11404 217 subscreens_overlay.clear();
11405
2/2
✓ Branch 0 taken 27776 times.
✓ Branch 1 taken 217 times.
27993 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11406 {
11407 subscreen_group g;
11408 27776 memset(&g,0,sizeof(subscreen_group));
11409 27776 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(ret!=0)
11411 return ret;
11412
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 26659 times.
27776 if(g.objects[0].type == ssoNULL) continue;
11413
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 650 times.
1117 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11414 1117 ZCSubscreen& sub = vec.emplace_back();
11415 1117 sub.load_old(g);
11416 1117 }
11417
11418 217 return 0;
11419 217 }
11420
11421 27776 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11422 {
11423 27776 int32_t numsub=0;
11424 27776 byte temp_ss=0;
11425 subscreen_object temp_sub_stack;
11426 27776 subscreen_object *temp_sub = &temp_sub_stack;
11427
11428 char tempname[64];
11429
11430 // FWIW I never saw anything bigger than 20.
11431 #define MAX_DP1_LEN 1024
11432 char tempdp1[MAX_DP1_LEN];
11433
11434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(!pfread(tempname,64,f))
11435 {
11436 return qe_invalid;
11437 }
11438
11439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version > 1)
11440 {
11441
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_getc(&temp_ss,f))
11442 {
11443 return qe_invalid;
11444 }
11445 27776 }
11446
11447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version < 4)
11448 {
11449 uint8_t tmp=0;
11450
11451 if(!p_getc(&tmp,f))
11452 {
11453 return qe_invalid;
11454 }
11455
11456 numsub = (int32_t)tmp;
11457 }
11458 else
11459 {
11460 word tmp;
11461
11462
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_igetw(&tmp, f))
11463 {
11464 return qe_invalid;
11465 }
11466
11467 27776 numsub = (int32_t)tmp;
11468 }
11469
11470 int32_t j;
11471
11472
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71950 times.
✓ Branch 2 taken 44174 times.
✓ Branch 3 taken 27776 times.
71950 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11473 {
11474 44174 memset(temp_sub,0,sizeof(subscreen_object));
11475
11476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 switch(g->objects[j].type)
11477 {
11478 case ssoTEXT:
11479 case ssoTEXTBOX:
11480 case ssoCURRENTITEMTEXT:
11481 case ssoCURRENTITEMCLASSTEXT:
11482 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11483
11484 //fall through
11485 default:
11486 44174 memset(&g->objects[j],0,sizeof(subscreen_object));
11487 44174 break;
11488 }
11489
11490
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->type),f))
11491 return qe_invalid;
11492
11493
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->pos),f))
11494 return qe_invalid;
11495
11496
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(s_version < 5)
11497 {
11498 switch(temp_sub->pos)
11499 {
11500 case 0:
11501 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11502 break;
11503
11504 case 1:
11505 temp_sub->pos = sspUP;
11506 break;
11507
11508 case 2:
11509 temp_sub->pos = sspDOWN;
11510 break;
11511
11512 default:
11513 temp_sub->pos = 0;
11514 }
11515 }
11516
11517
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->x),f))
11518 return qe_invalid;
11519
11520
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->y),f))
11521 return qe_invalid;
11522
11523
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->w),f))
11524 return qe_invalid;
11525
11526
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->h),f))
11527 return qe_invalid;
11528
11529
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype1),f))
11530 return qe_invalid;
11531
11532
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color1),f))
11533 return qe_invalid;
11534
11535
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype2),f))
11536 return qe_invalid;
11537
11538
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color2),f))
11539 return qe_invalid;
11540
11541
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype3),f))
11542 return qe_invalid;
11543
11544
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color3),f))
11545 return qe_invalid;
11546
11547
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d1),f))
11548 return qe_invalid;
11549
11550
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d2),f))
11551 return qe_invalid;
11552
11553
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d3),f))
11554 return qe_invalid;
11555
11556
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d4),f))
11557 return qe_invalid;
11558
11559
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d5),f))
11560 return qe_invalid;
11561
11562
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d6),f))
11563 return qe_invalid;
11564
11565
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d7),f))
11566 return qe_invalid;
11567
11568
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d8),f))
11569 return qe_invalid;
11570
11571
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d9),f))
11572 return qe_invalid;
11573
11574
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d10),f))
11575 return qe_invalid;
11576
11577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 if(s_version < 2)
11578 {
11579 if(!p_igetl(&(temp_sub->speed),f))
11580 return qe_invalid;
11581
11582 if(!p_igetl(&(temp_sub->delay),f))
11583 return qe_invalid;
11584
11585 if(!p_igetl(&(temp_sub->frame),f))
11586 return qe_invalid;
11587 }
11588 else
11589 {
11590
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->speed),f))
11591 return qe_invalid;
11592
11593
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->delay),f))
11594 return qe_invalid;
11595
11596
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->frame),f))
11597 return qe_invalid;
11598 }
11599
11600 44174 int32_t temp_size=0;
11601
11602 // bool deletets = false;
11603
4/4
✓ Branch 0 taken 19541 times.
✓ Branch 1 taken 3389 times.
✓ Branch 2 taken 21002 times.
✓ Branch 3 taken 242 times.
44174 switch(temp_sub->type)
11604 {
11605 case ssoTEXT:
11606 case ssoTEXTBOX:
11607 case ssoCURRENTITEMTEXT:
11608 case ssoCURRENTITEMCLASSTEXT:
11609 {
11610 word temptempsize;
11611
11612
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!p_igetw(&temptempsize,f))
11613 {
11614 return qe_invalid;
11615 }
11616
11617 //temptempsize = temp1 + (temp2 << 8);
11618 3389 temp_size = (int32_t)temptempsize;
11619 3389 uint32_t char_length = temp_size+2;
11620
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if (char_length > MAX_DP1_LEN)
11621 {
11622 return qe_invalid;
11623 }
11624 3389 tempdp1[char_length - 1] = '\0';
11625
11626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
3389 if(temp_size)
11627
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!pfread(tempdp1,temp_size+1,f))
11628 return qe_invalid;
11629 3389 break;
11630 }
11631
11632 case ssoLIFEMETER:
11633
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11634 temp_sub->d3 = 1;
11635
11636
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(!p_getc(&(temp_sub->dp1),f))
11637 return qe_invalid;
11638
11639 242 break;
11640
11641
11642 case ssoCURRENTITEM:
11643
11644
1/2
✓ Branch 0 taken 19541 times.
✗ Branch 1 not taken.
19541 if(s_version < 6)
11645 {
11646 switch(temp_sub->d1)
11647 {
11648 case ssiBOMB:
11649 temp_sub->d1 = itype_bomb;
11650 break;
11651
11652 case ssiSWORD:
11653 temp_sub->d1 = itype_sword;
11654 break;
11655
11656 case ssiSHIELD:
11657 temp_sub->d1 = itype_shield;
11658 break;
11659
11660 case ssiCANDLE:
11661 temp_sub->d1 = itype_candle;
11662 break;
11663
11664 case ssiLETTER:
11665 temp_sub->d1 = itype_letter;
11666 break;
11667
11668 case ssiPOTION:
11669 temp_sub->d1 = itype_potion;
11670 break;
11671
11672 case ssiLETTERPOTION:
11673 temp_sub->d1 = itype_letterpotion;
11674 break;
11675
11676 case ssiBOW:
11677 temp_sub->d1 = itype_bow;
11678 break;
11679
11680 case ssiARROW:
11681 temp_sub->d1 = itype_arrow;
11682 break;
11683
11684 case ssiBOWANDARROW:
11685 temp_sub->d1 = itype_bowandarrow;
11686 break;
11687
11688 case ssiBAIT:
11689 temp_sub->d1 = itype_bait;
11690 break;
11691
11692 case ssiRING:
11693 temp_sub->d1 = itype_ring;
11694 break;
11695
11696 case ssiBRACELET:
11697 temp_sub->d1 = itype_bracelet;
11698 break;
11699
11700 case ssiMAP:
11701 temp_sub->d1 = itype_map;
11702 break;
11703
11704 case ssiCOMPASS:
11705 temp_sub->d1 = itype_compass;
11706 break;
11707
11708 case ssiBOSSKEY:
11709 temp_sub->d1 = itype_bosskey;
11710 break;
11711
11712 case ssiMAGICKEY:
11713 temp_sub->d1 = itype_magickey;
11714 break;
11715
11716 case ssiBRANG:
11717 temp_sub->d1 = itype_brang;
11718 break;
11719
11720 case ssiWAND:
11721 temp_sub->d1 = itype_wand;
11722 break;
11723
11724 case ssiRAFT:
11725 temp_sub->d1 = itype_raft;
11726 break;
11727
11728 case ssiLADDER:
11729 temp_sub->d1 = itype_ladder;
11730 break;
11731
11732 case ssiWHISTLE:
11733 temp_sub->d1 = itype_whistle;
11734 break;
11735
11736 case ssiBOOK:
11737 temp_sub->d1 = itype_book;
11738 break;
11739
11740 case ssiWALLET:
11741 temp_sub->d1 = itype_wallet;
11742 break;
11743
11744 case ssiSBOMB:
11745 temp_sub->d1 = itype_sbomb;
11746 break;
11747
11748 case ssiHCPIECE:
11749 temp_sub->d1 = itype_heartpiece;
11750 break;
11751
11752 case ssiAMULET:
11753 temp_sub->d1 = itype_amulet;
11754 break;
11755
11756 case ssiFLIPPERS:
11757 temp_sub->d1 = itype_flippers;
11758 break;
11759
11760 case ssiHOOKSHOT:
11761 temp_sub->d1 = itype_hookshot;
11762 break;
11763
11764 case ssiLENS:
11765 temp_sub->d1 = itype_lens;
11766 break;
11767
11768 case ssiHAMMER:
11769 temp_sub->d1 = itype_hammer;
11770 break;
11771
11772 case ssiBOOTS:
11773 temp_sub->d1 = itype_boots;
11774 break;
11775
11776 case ssiDIVINEFIRE:
11777 temp_sub->d1 = itype_divinefire;
11778 break;
11779
11780 case ssiDIVINEESCAPE:
11781 temp_sub->d1 = itype_divineescape;
11782 break;
11783
11784 case ssiDIVINEPROTECTION:
11785 temp_sub->d1 = itype_divineprotection;
11786 break;
11787
11788 case ssiQUIVER:
11789 temp_sub->d1 = itype_quiver;
11790 break;
11791
11792 case ssiBOMBBAG:
11793 temp_sub->d1 = itype_bombbag;
11794 break;
11795
11796 case ssiCBYRNA:
11797 temp_sub->d1 = itype_cbyrna;
11798 break;
11799
11800 case ssiROCS:
11801 temp_sub->d1 = itype_rocs;
11802 break;
11803
11804 case ssiHOVERBOOTS:
11805 temp_sub->d1 = itype_hoverboots;
11806 break;
11807
11808 case ssiSPINSCROLL:
11809 temp_sub->d1 = itype_spinscroll;
11810 break;
11811
11812 case ssiCROSSSCROLL:
11813 temp_sub->d1 = itype_crossscroll;
11814 break;
11815
11816 case ssiQUAKESCROLL:
11817 temp_sub->d1 = itype_quakescroll;
11818 break;
11819
11820 case ssiWHISPRING:
11821 temp_sub->d1 = itype_whispring;
11822 break;
11823
11824 case ssiCHARGERING:
11825 temp_sub->d1 = itype_chargering;
11826 break;
11827
11828 case ssiPERILSCROLL:
11829 temp_sub->d1 = itype_perilscroll;
11830 break;
11831
11832 case ssiWEALTHMEDAL:
11833 temp_sub->d1 = itype_wealthmedal;
11834 break;
11835
11836 case ssiHEARTRING:
11837 temp_sub->d1 = itype_heartring;
11838 break;
11839
11840 case ssiMAGICRING:
11841 temp_sub->d1 = itype_magicring;
11842 break;
11843
11844 case ssiSPINSCROLL2:
11845 temp_sub->d1 = itype_spinscroll2;
11846 break;
11847
11848 case ssiQUAKESCROLL2:
11849 temp_sub->d1 = itype_quakescroll2;
11850 break;
11851
11852 case ssiAGONY:
11853 temp_sub->d1 = itype_agony;
11854 break;
11855
11856 case ssiSTOMPBOOTS:
11857 temp_sub->d1 = itype_stompboots;
11858 break;
11859
11860 case ssiWHIMSICALRING:
11861 temp_sub->d1 = itype_whimsicalring;
11862 break;
11863
11864 case ssiPERILRING:
11865 temp_sub->d1 = itype_perilring;
11866 break;
11867
11868 default:
11869 temp_sub->d1 += itype_custom1 - ssiMAX;
11870 }
11871 }
11872
11873 //fall-through
11874 default:
11875
1/2
✓ Branch 0 taken 40543 times.
✗ Branch 1 not taken.
40543 if(!p_getc(&(temp_sub->dp1),f))
11876 return qe_invalid;
11877
11878 40543 break;
11879 }
11880
11881
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 35480 times.
44174 if(s_version < 7)
11882 {
11883
3/3
✓ Branch 0 taken 29642 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 4568 times.
35480 switch(temp_sub->type)
11884 {
11885 case ssoMAGICGAUGE:
11886 {
11887
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1136 times.
1270 if(!temp_sub->d9)
11888 1136 temp_sub->d9 = -1; //-1 now represents 'always'
11889 1270 break;
11890 }
11891 case ssoLIFEGAUGE:
11892 4568 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11893 4568 break;
11894 }
11895 35480 }
11896
11897
3/3
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 39307 times.
✓ Branch 2 taken 1478 times.
44174 switch(temp_sub->type)
11898 {
11899 case ssoTEXT:
11900 case ssoTEXTBOX:
11901 case ssoCURRENTITEMTEXT:
11902 case ssoCURRENTITEMCLASSTEXT:
11903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3389 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11904
11905 3389 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11906 3389 g->objects[j].dp1 = new char[temp_size+2];
11907 3389 strcpy((char*)g->objects[j].dp1,tempdp1);
11908 3389 break;
11909
11910 case ssoCOUNTER:
11911
1/2
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
1478 if(s_version<3)
11912 {
11913 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11914 temp_sub->d8=0;
11915 }
11916
11917 default:
11918 40785 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11919 40785 break;
11920 }
11921
11922 44174 g->name[0] = '\0';
11923 44174 strncat(g->name, tempname, 64 - 1);
11924 44174 g->ss_type = temp_ss;
11925 44174 }
11926
11927
2/2
✓ Branch 0 taken 7066482 times.
✓ Branch 1 taken 27776 times.
7094258 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11928 {
11929 //clear all unused object in this subscreen -DD
11930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066482 times.
7066482 switch(g->objects[j].type)
11931 {
11932 case ssoTEXT:
11933 case ssoTEXTBOX:
11934 case ssoCURRENTITEMTEXT:
11935 case ssoCURRENTITEMCLASSTEXT:
11936 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11937
11938 //fall through
11939 default:
11940 7066482 memset(&g->objects[j],0,sizeof(subscreen_object));
11941 7066482 break;
11942 }
11943 7066482 }
11944
11945 27776 return 0;
11946 27776 }
11947
11948 398 int32_t readsubscreens(PACKFILE *f)
11949 {
11950 word s_version;
11951 dword dummy;
11952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
11953 return qe_invalid;
11954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_SUBSCREEN)
11955 return qe_version;
11956 398 FFCore.quest_format[vSubscreen] = s_version;
11957
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
11958 return qe_invalid;
11959
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f)) //section size
11960 return qe_invalid;
11961
11962
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version < 8)
11963 217 return read_old_subscreens(f,s_version);
11964
11965 181 subscreens_active.clear();
11966 181 subscreens_passive.clear();
11967 181 subscreens_overlay.clear();
11968
11969 byte sz;
11970
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_getc(&sz,f))
11971 return qe_invalid;
11972
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 181 times.
770 for(byte q = 0; q < sz; ++q)
11973 {
11974 589 ZCSubscreen& tmp = subscreens_active.emplace_back();
11975
1/2
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
589 if (auto ret = tmp.read(f, s_version))
11976 return ret;
11977 589 }
11978
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_getc(&sz,f))
11979 return qe_invalid;
11980
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 181 times.
873 for(byte q = 0; q < sz; ++q)
11981 {
11982 692 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11983
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if (auto ret = tmp.read(f, s_version))
11984 return ret;
11985 692 }
11986
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_getc(&sz,f))
11987 return qe_invalid;
11988
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 181 times.
191 for(byte q = 0; q < sz; ++q)
11989 {
11990 10 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (auto ret = tmp.read(f, s_version))
11992 return ret;
11993 10 }
11994 181 return 0;
11995 398 }
11996
11997 void reset_subscreen(subscreen_group *tempss)
11998 {
11999 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12000 {
12001 switch(tempss->objects[i].type)
12002 {
12003 case ssoTEXT:
12004 case ssoTEXTBOX:
12005 case ssoCURRENTITEMTEXT:
12006 case ssoCURRENTITEMCLASSTEXT:
12007 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12008
12009 //fall through
12010 default:
12011 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12012 break;
12013 }
12014 }
12015 }
12016
12017 117 void reset_subscreens()
12018 {
12019 117 subscreens_active.clear();
12020 117 subscreens_passive.clear();
12021 117 subscreens_overlay.clear();
12022 117 }
12023
12024 117 int32_t setupsubscreens()
12025 {
12026 117 reset_subscreens();
12027 //return 0;
12028
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12029 {
12030 234 subscreens_active.emplace_back();
12031 234 subscreens_passive.emplace_back();
12032 234 }
12033 117 int32_t tempsubscreen=subscr_mode;
12034
12035
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12036 tempsubscreen=0;
12037
12038
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12039 {
12040 case ssdtOLD:
12041 case ssdtNEWSUBSCR:
12042 case ssdtREV2:
12043 case ssdtBSZELDA:
12044 case ssdtBSZELDAMODIFIED:
12045 case ssdtBSZELDAENHANCED:
12046 case ssdtBSZELDACOMPLETE:
12047 {
12048 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12049 117 subscreens_active[0].sub_type=sstACTIVE;
12050 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12051 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12052 117 subscreens_active[1].sub_type=sstACTIVE;
12053 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12054 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12055 117 subscreens_passive[0].sub_type=sstPASSIVE;
12056 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12057 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12058 117 subscreens_passive[1].sub_type=sstPASSIVE;
12059 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12060 117 break;
12061 }
12062
12063 case ssdtZ3:
12064 {
12065 subscreens_active[0].load_old(z3_active_a);
12066 subscreens_active[0].sub_type=sstACTIVE;
12067 subscreens_active[1].load_old(z3_active_ab);
12068 subscreens_active[1].sub_type=sstACTIVE;
12069 subscreens_passive[0].load_old(z3_passive_a);
12070 subscreens_passive[0].sub_type=sstPASSIVE;
12071 subscreens_passive[1].load_old(z3_passive_ab);
12072 subscreens_passive[1].sub_type=sstPASSIVE;
12073 break;
12074 }
12075 }
12076 117 subscr_mode = ssdtMAX;
12077 117 return 0;
12078 }
12079
12080 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12081
12082 extern script_data *ffscripts[NUMSCRIPTFFC];
12083 extern script_data *itemscripts[NUMSCRIPTITEM];
12084 extern script_data *guyscripts[NUMSCRIPTGUYS];
12085 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12086 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12087 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12088 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12089 extern script_data *playerscripts[NUMSCRIPTHERO];
12090 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12091 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12092 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12093 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12094 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12095
12096 static std::vector<const script_data*> read_scripts;
12097
12098 430 static script_data fake_script_data(ScriptType::None, 0);
12099
12100 528 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12101 {
12102 int32_t dummy;
12103 528 word s_version=0, zmeta_version=0;
12104 528 byte numscripts=0;
12105 528 numscripts=numscripts; //to avoid unused variables warnings
12106 int32_t ret;
12107 528 read_scripts.clear();
12108 528 zasm_scripts.clear();
12109
12110 //section version info
12111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if(!p_igetw(&s_version,f))
12112 {
12113 return qe_invalid;
12114 }
12115
12116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
528 if (s_version > V_FFSCRIPT)
12117 return qe_version;
12118
12119 528 FFCore.quest_format[vFFScript] = s_version;
12120
12121
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!read_deprecated_section_cversion(f))
12122 {
12123 return qe_invalid;
12124 }
12125
12126
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 198 times.
528 if(s_version >= 18)
12127 {
12128
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&zmeta_version,f))
12129 {
12130 return qe_invalid;
12131 }
12132 198 }
12133
12134 //section size
12135
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(!p_igetl(&dummy,f))
12136 {
12137 return qe_invalid;
12138 }
12139
12140
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 219 times.
528 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12141 528 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12142
12143
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 132 times.
528 if(s_version >= 27)
12144 {
12145 132 ret = read_quest_zasm(f, s_version);
12146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(ret)
12147 return qe_invalid;
12148 132 }
12149
12150 //finally... section data
12151
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 466 times.
204242 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12152 {
12153 203776 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12154
12155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if (ret)
12156 {
12157 return qe_invalid;
12158 }
12159 203776 }
12160
12161 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12162 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12163 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12164 * there was a version bump a week before a change that broke stuff.
12165 */
12166
7/8
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
✓ Branch 4 taken 198 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 198 times.
✓ Branch 7 taken 198 times.
466 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12167 {
12168 664 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12169 664 }
12170
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version < 19)
12171 {
12172 200 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12173 200 }
12174
12175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 1)
12176 {
12177
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12178 {
12179 101888 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12180
12181
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12182 {
12183 return qe_invalid;
12184 }
12185 101888 }
12186
12187
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12188 {
12189 101888 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12190
12191
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12192 {
12193 return qe_invalid;
12194 }
12195 101888 }
12196
12197
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12198 {
12199 101888 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12200
12201
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12202 {
12203 return qe_invalid;
12204 }
12205 101888 }
12206
12207
2/2
✓ Branch 0 taken 101888 times.
✓ Branch 1 taken 398 times.
102286 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12208 {
12209 101888 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12210
12211
1/2
✓ Branch 0 taken 101888 times.
✗ Branch 1 not taken.
101888 if (ret)
12212 {
12213 return qe_invalid;
12214 }
12215 101888 }
12216
12217
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version > 16)
12218 {
12219
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 198 times.
1782 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12220 {
12221 1584 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12222
12223
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if (ret)
12224 {
12225 return qe_invalid;
12226 }
12227 1584 }
12228 198 }
12229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 else if(s_version > 13)
12230 {
12231 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12232 {
12233 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12234
12235 if (ret)
12236 {
12237 return qe_invalid;
12238 }
12239 }
12240
12241 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12242 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12243
12244 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12245 }
12246
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 else if(s_version > 4)
12247 {
12248
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12249 {
12250 800 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12251
12252
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (ret)
12253 {
12254 return qe_invalid;
12255 }
12256 800 }
12257
12258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12259
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12260
12261
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12262
12263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12264
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12265
12266
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12267
12268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12269
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_F6];
12270
12271
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12272
12273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12274
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12275
12276
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12277 200 }
12278 else
12279 {
12280 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12281 {
12282 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12283
12284 if (ret)
12285 {
12286 return qe_invalid;
12287 }
12288 }
12289
12290 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12291 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12292
12293 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12294
12295 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12296 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12297
12298 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12299
12300 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12301 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12302
12303 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12304
12305 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12306 delete globalscripts[GLOBAL_SCRIPT_F6];
12307
12308 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12309
12310 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12311 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12312
12313 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12314 }
12315
12316
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(s_version > 10) //expanded the number of Hero scripts to 5.
12317 {
12318
2/2
✓ Branch 0 taken 990 times.
✓ Branch 1 taken 198 times.
1188 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12319 {
12320 990 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12321
12322
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if (ret)
12323 {
12324 return qe_invalid;
12325 }
12326 990 }
12327 198 }
12328 else
12329 {
12330
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 200 times.
800 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12331 {
12332 600 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12333
12334
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 if (ret)
12335 {
12336 return qe_invalid;
12337 }
12338 600 }
12339
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[3] != NULL)
12340
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete playerscripts[3];
12341
12342
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12343
12344
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[4] != NULL)
12345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 delete playerscripts[4];
12346
12347
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12348 }
12349
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
398 if(s_version > 8 && s_version < 10)
12350 {
12351
12352 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12353 {
12354 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12355
12356 if (ret)
12357 {
12358 return qe_invalid;
12359 }
12360 }
12361 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12362 {
12363 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12364
12365 if (ret)
12366 {
12367 return qe_invalid;
12368 }
12369 }
12370
12371 }
12372
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >= 10)
12373 {
12374
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12375 {
12376 50688 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12377
12378
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12379 {
12380 return qe_invalid;
12381 }
12382 50688 }
12383
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12384 {
12385 50688 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12386
12387
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12388 {
12389 return qe_invalid;
12390 }
12391 50688 }
12392
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12393 {
12394 50688 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12395
12396
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12397 {
12398 return qe_invalid;
12399 }
12400 50688 }
12401
12402 198 }
12403
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >=12)
12404 {
12405
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12406 {
12407 50688 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12408
12409
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 if (ret)
12410 {
12411 return qe_invalid;
12412 }
12413 50688 }
12414 198 }
12415
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >=15)
12416 {
12417
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 198 times.
101574 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12418 {
12419 101376 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12420
12421
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if (ret)
12422 {
12423 return qe_invalid;
12424 }
12425 101376 }
12426 198 }
12427
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >19)
12428 {
12429 198 word numgenscripts = NUMSCRIPTSGENERIC;
12430
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetw(&numgenscripts,f))
12431 {
12432 return qe_invalid;
12433 }
12434
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 198 times.
101574 for(int32_t i = 0; i < numgenscripts; i++)
12435 {
12436 101376 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12437
12438
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if (ret)
12439 {
12440 return qe_invalid;
12441 }
12442 101376 }
12443 198 }
12444
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version >21)
12445 {
12446 181 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12447
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&numsubscripts,f))
12448 {
12449 return qe_invalid;
12450 }
12451
2/2
✓ Branch 0 taken 46336 times.
✓ Branch 1 taken 181 times.
46517 for(int32_t i = 0; i < numsubscripts; i++)
12452 {
12453 46336 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12454
12455
1/2
✓ Branch 0 taken 46336 times.
✗ Branch 1 not taken.
46336 if (ret)
12456 {
12457 return qe_invalid;
12458 }
12459 46336 }
12460 181 }
12461 398 }
12462
12463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 2)
12464 {
12465 int32_t bufsize;
12466 398 p_igetl(&bufsize, f);
12467
2/4
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
398 if (bufsize < 0 || bufsize > 1024*1024*10)
12468 {
12469 // God help anyone storing more than 10MB of code in the script buffer.
12470 return qe_invalid;
12471 }
12472 398 char * buf = new char[bufsize+1];
12473 398 pfread(buf, bufsize, f);
12474 398 buf[bufsize]=0;
12475
12476
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 zScript = string(buf);
12477
12478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 delete[] buf;
12479 word numffcbindings;
12480 398 p_igetw(&numffcbindings, f);
12481
12482
2/2
✓ Branch 0 taken 10853 times.
✓ Branch 1 taken 398 times.
11251 for(int32_t i=0; i<numffcbindings; i++)
12483 {
12484 word id;
12485 10853 p_igetw(&id, f);
12486 10853 p_igetl(&bufsize, f);
12487
2/4
✓ Branch 0 taken 10853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10853 times.
10853 if (bufsize < 0 || bufsize > 1024)
12488 return qe_invalid;
12489 10853 buf = new char[bufsize+1];
12490 10853 pfread(buf, bufsize, f);
12491 10853 buf[bufsize]=0;
12492
12493 //fix for buggy older saved quests -DD
12494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10853 times.
10853 if(id < NUMSCRIPTFFC-1)
12495 10853 ffcmap[id].scriptname = buf;
12496
12497
1/2
✓ Branch 0 taken 10853 times.
✗ Branch 1 not taken.
10853 delete[] buf;
12498 10853 }
12499
12500 word numglobalbindings;
12501 398 p_igetw(&numglobalbindings, f);
12502
12503
2/2
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 398 times.
1977 for(int32_t i=0; i<numglobalbindings; i++)
12504 {
12505 word id;
12506 1579 p_igetw(&id, f);
12507 1579 p_igetl(&bufsize, f);
12508
2/4
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1579 times.
✗ Branch 3 not taken.
1579 if (bufsize < 0 || bufsize > 1024)
12509 return qe_invalid;
12510 1579 buf = new char[bufsize+1];
12511 1579 pfread(buf, bufsize, f);
12512 1579 buf[bufsize]=0;
12513
12514 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12515 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12516 // Ignore these. -DD
12517
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1033 times.
1579 if (id < NUMSCRIPTGLOBAL)
12518 {
12519 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12520
1/2
✓ Branch 0 taken 1033 times.
✗ Branch 1 not taken.
1033 if(strcmp(buf,"~Continue") == 0)
12521 {
12522 globalmap[id].scriptname = "";
12523
12524 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12525 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12526 }
12527 else
12528 {
12529 1033 globalmap[id].scriptname = buf;
12530 }
12531 1033 }
12532
12533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 delete[] buf;
12534 1579 }
12535
12536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version > 3)
12537 {
12538 word numitembindings;
12539 398 p_igetw(&numitembindings, f);
12540
12541
2/2
✓ Branch 0 taken 1285 times.
✓ Branch 1 taken 398 times.
1683 for(int32_t i=0; i<numitembindings; i++)
12542 {
12543 word id;
12544 1285 p_igetw(&id, f);
12545 1285 p_igetl(&bufsize, f);
12546
2/4
✓ Branch 0 taken 1285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1285 times.
1285 if (bufsize < 0 || bufsize > 1024)
12547 return qe_invalid;
12548 1285 buf = new char[bufsize+1];
12549 1285 pfread(buf, bufsize, f);
12550 1285 buf[bufsize]=0;
12551
12552 //fix this too
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1285 times.
1285 if(id <NUMSCRIPTITEM-1)
12554 1285 itemmap[id].scriptname = buf;
12555
12556
1/2
✓ Branch 0 taken 1285 times.
✗ Branch 1 not taken.
1285 delete[] buf;
12557 1285 }
12558 398 }
12559 //(v9+)
12560
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version > 8)
12561 {
12562 //npc scripts
12563 word numnpcbindings;
12564 198 p_igetw(&numnpcbindings, f);
12565
12566
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 198 times.
230 for(int32_t i=0; i<numnpcbindings; i++)
12567 {
12568 word id;
12569 32 p_igetw(&id, f);
12570 32 p_igetl(&bufsize, f);
12571
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if (bufsize < 0 || bufsize > 1024)
12572 return qe_invalid;
12573 32 buf = new char[bufsize+1];
12574 32 pfread(buf, bufsize, f);
12575 32 buf[bufsize]=0;
12576
12577 //fix this too
12578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(id <NUMSCRIPTGUYS-1)
12579 32 npcmap[id].scriptname = buf;
12580
12581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 delete[] buf;
12582 32 }
12583 //lweapon
12584 word numlwpnbindings;
12585 198 p_igetw(&numlwpnbindings, f);
12586
12587
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 198 times.
535 for(int32_t i=0; i<numlwpnbindings; i++)
12588 {
12589 word id;
12590 337 p_igetw(&id, f);
12591 337 p_igetl(&bufsize, f);
12592
2/4
✓ Branch 0 taken 337 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 337 times.
337 if (bufsize < 0 || bufsize > 1024)
12593 return qe_invalid;
12594 337 buf = new char[bufsize+1];
12595 337 pfread(buf, bufsize, f);
12596 337 buf[bufsize]=0;
12597
12598 //fix this too
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 if(id <NUMSCRIPTWEAPONS-1)
12600 337 lwpnmap[id].scriptname = buf;
12601
12602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 337 times.
337 delete[] buf;
12603 337 }
12604 //eweapon
12605 word numewpnbindings;
12606 198 p_igetw(&numewpnbindings, f);
12607
12608
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 198 times.
495 for(int32_t i=0; i<numewpnbindings; i++)
12609 {
12610 word id;
12611 297 p_igetw(&id, f);
12612 297 p_igetl(&bufsize, f);
12613
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if (bufsize < 0 || bufsize > 1024)
12614 return qe_invalid;
12615 297 buf = new char[bufsize+1];
12616 297 pfread(buf, bufsize, f);
12617 297 buf[bufsize]=0;
12618
12619 //fix this too
12620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(id <NUMSCRIPTWEAPONS-1)
12621 297 ewpnmap[id].scriptname = buf;
12622
12623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 delete[] buf;
12624 297 }
12625 //hero
12626 word numherobindings;
12627 198 p_igetw(&numherobindings, f);
12628
12629
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 198 times.
221 for(int32_t i=0; i<numherobindings; i++)
12630 {
12631 word id;
12632 23 p_igetw(&id, f);
12633 23 p_igetl(&bufsize, f);
12634
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12635 return qe_invalid;
12636 23 buf = new char[bufsize+1];
12637 23 pfread(buf, bufsize, f);
12638 23 buf[bufsize]=0;
12639
12640 //fix this too
12641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTHERO-1)
12642 23 playermap[id].scriptname = buf;
12643
12644
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12645 23 }
12646 //dmaps
12647 word numdmapbindings;
12648 198 p_igetw(&numdmapbindings, f);
12649
12650
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 198 times.
651 for(int32_t i=0; i<numdmapbindings; i++)
12651 {
12652 word id;
12653 453 p_igetw(&id, f);
12654 453 p_igetl(&bufsize, f);
12655
2/4
✓ Branch 0 taken 453 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 453 times.
453 if (bufsize < 0 || bufsize > 1024)
12656 return qe_invalid;
12657 453 buf = new char[bufsize+1];
12658 453 pfread(buf, bufsize, f);
12659 453 buf[bufsize]=0;
12660
12661 //fix this too
12662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 453 times.
453 if(id <NUMSCRIPTSDMAP-1)
12663 453 dmapmap[id].scriptname = buf;
12664
12665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 453 times.
453 delete[] buf;
12666 453 }
12667 //screen
12668 word numscreenbindings;
12669 198 p_igetw(&numscreenbindings, f);
12670
12671
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 198 times.
617 for(int32_t i=0; i<numscreenbindings; i++)
12672 {
12673 word id;
12674 419 p_igetw(&id, f);
12675 419 p_igetl(&bufsize, f);
12676
2/4
✓ Branch 0 taken 419 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 419 times.
✗ Branch 3 not taken.
419 if (bufsize < 0 || bufsize > 1024)
12677 return qe_invalid;
12678 419 buf = new char[bufsize+1];
12679 419 pfread(buf, bufsize, f);
12680 419 buf[bufsize]=0;
12681
12682 //fix this too
12683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 if(id <NUMSCRIPTSDMAP-1)
12684 419 screenmap[id].scriptname = buf;
12685
12686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419 times.
419 delete[] buf;
12687 419 }
12688 198 }
12689
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version > 11)
12690 {
12691 word numspritebindings;
12692 198 p_igetw(&numspritebindings, f);
12693
12694
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 198 times.
249 for(int32_t i=0; i<numspritebindings; i++)
12695 {
12696 word id;
12697 51 p_igetw(&id, f);
12698 51 p_igetl(&bufsize, f);
12699
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
51 if (bufsize < 0 || bufsize > 1024)
12700 return qe_invalid;
12701 51 buf = new char[bufsize+1];
12702 51 pfread(buf, bufsize, f);
12703 51 buf[bufsize]=0;
12704
12705 //fix this too
12706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(id <NUMSCRIPTSDMAP-1)
12707 51 itemspritemap[id].scriptname = buf;
12708
12709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 delete[] buf;
12710 51 }
12711 198 }
12712
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version >= 15)
12713 {
12714 word numcombobindings;
12715 198 p_igetw(&numcombobindings, f);
12716
12717
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 198 times.
355 for(int32_t i=0; i<numcombobindings; i++)
12718 {
12719 word id;
12720 157 p_igetw(&id, f);
12721 157 p_igetl(&bufsize, f);
12722
2/4
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
157 if (bufsize < 0 || bufsize > 1024)
12723 return qe_invalid;
12724 157 buf = new char[bufsize+1];
12725 157 pfread(buf, bufsize, f);
12726 157 buf[bufsize]=0;
12727
12728 //fix this too
12729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(id <NUMSCRIPTSCOMBODATA-1)
12730 157 comboscriptmap[id].scriptname = buf;
12731
12732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 delete[] buf;
12733 157 }
12734 198 }
12735
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if(s_version > 19)
12736 {
12737 word numgenericbindings;
12738 198 p_igetw(&numgenericbindings, f);
12739
12740
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 198 times.
2446 for(int32_t i=0; i<numgenericbindings; i++)
12741 {
12742 word id;
12743 2248 p_igetw(&id, f);
12744 2248 p_igetl(&bufsize, f);
12745
2/4
✓ Branch 0 taken 2248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2248 times.
✗ Branch 3 not taken.
2248 if (bufsize < 0 || bufsize > 1024)
12746 return qe_invalid;
12747 2248 buf = new char[bufsize+1];
12748 2248 pfread(buf, bufsize, f);
12749 2248 buf[bufsize]=0;
12750
12751 //fix this too
12752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
2248 if(id <NUMSCRIPTSGENERIC-1)
12753 2248 genericmap[id].scriptname = buf;
12754
12755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
2248 delete[] buf;
12756 2248 }
12757 198 }
12758
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version > 21)
12759 {
12760 word numsubscreenbindings;
12761 181 p_igetw(&numsubscreenbindings, f);
12762
12763
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 181 times.
189 for(int32_t i=0; i<numsubscreenbindings; i++)
12764 {
12765 word id;
12766 8 p_igetw(&id, f);
12767 8 p_igetl(&bufsize, f);
12768
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (bufsize < 0 || bufsize > 1024)
12769 return qe_invalid;
12770 8 buf = new char[bufsize+1];
12771 8 pfread(buf, bufsize, f);
12772 8 buf[bufsize]=0;
12773
12774 //fix this too
12775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(id <NUMSCRIPTSSUBSCREEN-1)
12776 8 subscreenmap[id].scriptname = buf;
12777
12778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 delete[] buf;
12779 8 }
12780 181 }
12781 398 }
12782
12783 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12784 // This is only updated when the scripts have been recompiled.
12785 // They should all match each other.
12786 398 std::optional<word> zscript_version;
12787
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 198 times.
398 if (s_version >= 16)
12788 {
12789
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 7706 times.
7902 for (auto script : read_scripts)
12790 {
12791
2/2
✓ Branch 0 taken 7704 times.
✓ Branch 1 taken 2 times.
7706 if (script->meta.ffscript_v == 0)
12792 {
12793 // These scripts were saved in a version prior to this field being set.
12794 // See https://discord.com/channels/876899628556091432/1368485306394738718
12795 2 zscript_version = 16;
12796 2 break;
12797 }
12798
1/2
✓ Branch 0 taken 7704 times.
✗ Branch 1 not taken.
7704 if (script->meta.ffscript_v > s_version)
12799 break;
12800
12801
2/2
✓ Branch 0 taken 7526 times.
✓ Branch 1 taken 178 times.
7704 if (!zscript_version.has_value())
12802 {
12803 178 zscript_version = script->meta.ffscript_v;
12804 178 continue;
12805 }
12806
12807
1/2
✓ Branch 0 taken 7526 times.
✗ Branch 1 not taken.
7526 if (zscript_version.value() != script->meta.ffscript_v)
12808 {
12809 zscript_version.reset();
12810 break;
12811 }
12812 }
12813
12814
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 18 times.
198 if (!zscript_version.has_value())
12815 18 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12816 198 }
12817 398 setZScriptVersion(zscript_version.value_or(s_version));
12818 398 read_scripts.clear();
12819
12820 398 return 0;
12821 398 }
12822
12823 void(*reset_scripts_hook)();
12824
12825 480 void reset_scripts()
12826 {
12827 // We can't modify the script data while jit threads are possibly compiling them.
12828
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 469 times.
480 if (reset_scripts_hook)
12829 469 reset_scripts_hook();
12830
12831
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12832 {
12833
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12834 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12835 245760 }
12836
12837
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12838 {
12839
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (ffscripts[i])
12840 245760 ffscripts[i]->disable();
12841 else
12842 ffscripts[i] = new script_data(ScriptType::FFC, i);
12843 245760 }
12844
12845
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12846 {
12847
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (itemscripts[i])
12848 122880 itemscripts[i]->disable();
12849 else
12850 itemscripts[i] = new script_data(ScriptType::Item, i);
12851 122880 }
12852
12853
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12854 {
12855
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (guyscripts[i])
12856 122880 guyscripts[i]->disable();
12857 else
12858 guyscripts[i] = new script_data(ScriptType::NPC, i);
12859 122880 }
12860
12861
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12862 {
12863
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (screenscripts[i])
12864 122880 screenscripts[i]->disable();
12865 else
12866 screenscripts[i] = new script_data(ScriptType::Screen, i);
12867 122880 }
12868
12869
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 480 times.
4320 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12870 {
12871
1/2
✓ Branch 0 taken 3840 times.
✗ Branch 1 not taken.
3840 if (globalscripts[i])
12872 3840 globalscripts[i]->disable();
12873 else
12874 globalscripts[i] = new script_data(ScriptType::Global, i);
12875 3840 }
12876
12877
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 480 times.
2880 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12878 {
12879
1/2
✓ Branch 0 taken 2400 times.
✗ Branch 1 not taken.
2400 if (playerscripts[i])
12880 2400 playerscripts[i]->disable();
12881 else
12882 playerscripts[i] = new script_data(ScriptType::Hero, i);
12883 2400 }
12884
12885
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12886 {
12887
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (lwpnscripts[i])
12888 122880 lwpnscripts[i]->disable();
12889 else
12890 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12891 122880 }
12892
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12893 {
12894
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (ewpnscripts[i])
12895 122880 ewpnscripts[i]->disable();
12896 else
12897 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12898 122880 }
12899
12900
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12901 {
12902
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (dmapscripts[i])
12903 122880 dmapscripts[i]->disable();
12904 else
12905 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12906 122880 }
12907
2/2
✓ Branch 0 taken 122880 times.
✓ Branch 1 taken 480 times.
123360 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12908 {
12909
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (itemspritescripts[i])
12910 122880 itemspritescripts[i]->disable();
12911 else
12912 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12913 122880 }
12914
2/2
✓ Branch 0 taken 245760 times.
✓ Branch 1 taken 480 times.
246240 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12915 {
12916
1/2
✓ Branch 0 taken 245760 times.
✗ Branch 1 not taken.
245760 if (comboscripts[i])
12917 245760 comboscripts[i]->disable();
12918 else
12919 comboscripts[i] = new script_data(ScriptType::Combo, i);
12920 245760 }
12921
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 122880 times.
123360 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12922 {
12923
1/2
✓ Branch 0 taken 122880 times.
✗ Branch 1 not taken.
122880 if (subscreenscripts[i])
12924 122880 subscreenscripts[i]->disable();
12925 else
12926 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12927 122880 }
12928 480 }
12929
12930 // 3.0+ calls this.
12931 132 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12932 {
12933 int32_t num_commands;
12934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_igetl(&num_commands,f))
12935 return qe_invalid;
12936 #ifdef ZC_FUZZ
12937 const int32_t command_limit = 300000;
12938 #else
12939 132 const int32_t command_limit = 25000000;
12940 #endif
12941
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if (num_commands < 0 || num_commands > command_limit)
12942 return qe_invalid;
12943
12944 132 std::vector<ffscript> zasm;
12945
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 zasm.reserve(num_commands);
12946
2/2
✓ Branch 0 taken 3396230 times.
✓ Branch 1 taken 132 times.
3396362 for(int32_t j=0; j<num_commands; j++)
12947 {
12948
1/2
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
3396230 ffscript temp_script;
12949
2/4
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3396230 times.
✗ Branch 3 not taken.
3396230 if(!p_igetw(&(temp_script.command),f))
12950 return qe_invalid;
12951
12952
2/4
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3396230 times.
✗ Branch 3 not taken.
3396230 if(!p_igetl(&(temp_script.arg1),f))
12953 return qe_invalid;
12954
12955
2/4
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3396230 times.
✗ Branch 3 not taken.
3396230 if(!p_igetl(&(temp_script.arg2),f))
12956 return qe_invalid;
12957
12958
2/4
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3396230 times.
✗ Branch 3 not taken.
3396230 if(!p_igetl(&(temp_script.arg3),f))
12959 return qe_invalid;
12960
12961 3396230 uint32_t sz = 0;
12962
2/4
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3396230 times.
✗ Branch 3 not taken.
3396230 if(!p_igetl(&sz,f))
12963 return qe_invalid;
12964
2/2
✓ Branch 0 taken 41281 times.
✓ Branch 1 taken 3354949 times.
3396230 if(sz) //string found
12965 {
12966
1/2
✓ Branch 0 taken 41281 times.
✗ Branch 1 not taken.
41281 temp_script.strptr = new std::string();
12967 char dummy;
12968
2/2
✓ Branch 0 taken 752021 times.
✓ Branch 1 taken 41281 times.
793302 for(size_t q = 0; q < sz; ++q)
12969 {
12970
2/4
✓ Branch 0 taken 752021 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 752021 times.
✗ Branch 3 not taken.
752021 if(!p_getc(&dummy,f))
12971 return qe_invalid;
12972
1/2
✓ Branch 0 taken 752021 times.
✗ Branch 1 not taken.
752021 temp_script.strptr->push_back(dummy);
12973 752021 }
12974 41281 }
12975
2/4
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3396230 times.
✗ Branch 3 not taken.
3396230 if(!p_igetl(&sz,f))
12976 return qe_invalid;
12977
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 3389733 times.
3396230 if(sz) //vector found
12978 {
12979
1/2
✓ Branch 0 taken 6497 times.
✗ Branch 1 not taken.
6497 temp_script.vecptr = new std::vector<int32_t>();
12980 int32_t dummy;
12981
2/2
✓ Branch 0 taken 18469 times.
✓ Branch 1 taken 6497 times.
24966 for(size_t q = 0; q < sz; ++q)
12982 {
12983
2/4
✓ Branch 0 taken 18469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18469 times.
✗ Branch 3 not taken.
18469 if(!p_igetl(&dummy,f))
12984 return qe_invalid;
12985
1/2
✓ Branch 0 taken 18469 times.
✗ Branch 1 not taken.
18469 temp_script.vecptr->push_back(dummy);
12986 18469 }
12987 6497 }
12988
1/2
✓ Branch 0 taken 3396230 times.
✗ Branch 1 not taken.
3396230 zasm.emplace_back(std::move(temp_script));
12989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3396230 times.
3396230 }
12990
12991
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 assert(zasm_scripts.empty());
12992 132 zasm_script_id id = zasm_scripts.size();
12993
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
12994
12995 132 return 0;
12996 132 }
12997
12998 1067142 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
12999 {
13000 ASSERT(script);
13001
2/2
✓ Branch 0 taken 558546 times.
✓ Branch 1 taken 508596 times.
1067142 if(s_version < 27)
13002 558546 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
13003
13004 char exists;
13005
1/2
✓ Branch 0 taken 508596 times.
✗ Branch 1 not taken.
508596 if (!p_getc(&exists, f))
13006 return qe_invalid;
13007
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 503934 times.
508596 if (!exists)
13008 {
13009 503934 script->disable();
13010 503934 return 0;
13011 }
13012
13013 //Read meta
13014 {
13015 4662 zasm_meta temp_meta;
13016
13017
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.zasm_v),f))
13018 return qe_invalid;
13019
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.meta_v),f))
13020 return qe_invalid;
13021
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.ffscript_v),f))
13022 return qe_invalid;
13023
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getc(&(temp_meta.script_type),f))
13024 return qe_invalid;
13025
13026
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(int32_t q = 0; q < 8; ++q)
13027 {
13028
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.run_idens[q],f))
13029 return qe_invalid;
13030 37296 }
13031
13032
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 37296 times.
41958 for(int32_t q = 0; q < 8; ++q)
13033
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getc(&(temp_meta.run_types[q]),f))
13034 return qe_invalid;
13035
13036
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getc(&(temp_meta.flags),f))
13037 return qe_invalid;
13038
13039
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v1),f))
13040 return qe_invalid;
13041
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v2),f))
13042 return qe_invalid;
13043
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v3),f))
13044 return qe_invalid;
13045
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_igetw(&(temp_meta.compiler_v4),f))
13046 return qe_invalid;
13047
13048
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getcstr(&temp_meta.script_name,f))
13049 return qe_invalid;
13050
2/4
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
✗ Branch 3 not taken.
4662 if(!p_getcstr(&temp_meta.author,f))
13051 return qe_invalid;
13052 4662 auto num_meta_attrib = 10;
13053
2/2
✓ Branch 0 taken 46620 times.
✓ Branch 1 taken 4662 times.
51282 for(auto q = 0; q < num_meta_attrib; ++q)
13054 {
13055
2/4
✓ Branch 0 taken 46620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46620 times.
✗ Branch 3 not taken.
46620 if(!p_getcstr(&temp_meta.attributes[q],f))
13056 return qe_invalid;
13057
2/4
✓ Branch 0 taken 46620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46620 times.
✗ Branch 3 not taken.
46620 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13058 return qe_invalid;
13059 46620 }
13060
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(auto q = 0; q < 8; ++q)
13061 {
13062
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.attribytes[q],f))
13063 return qe_invalid;
13064
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13065 return qe_invalid;
13066 37296 }
13067
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(auto q = 0; q < 8; ++q)
13068 {
13069
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13070 return qe_invalid;
13071
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13072 return qe_invalid;
13073 37296 }
13074
2/2
✓ Branch 0 taken 74592 times.
✓ Branch 1 taken 4662 times.
79254 for(auto q = 0; q < 16; ++q)
13075 {
13076
2/4
✓ Branch 0 taken 74592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74592 times.
✗ Branch 3 not taken.
74592 if(!p_getcstr(&temp_meta.usrflags[q],f))
13077 return qe_invalid;
13078
2/4
✓ Branch 0 taken 74592 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74592 times.
✗ Branch 3 not taken.
74592 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13079 return qe_invalid;
13080 74592 }
13081
2/2
✓ Branch 0 taken 37296 times.
✓ Branch 1 taken 4662 times.
41958 for(auto q = 0; q < 8; ++q)
13082 {
13083
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getcstr(&temp_meta.initd[q],f))
13084 return qe_invalid;
13085
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getwstr(&temp_meta.initd_help[q],f))
13086 return qe_invalid;
13087 37296 }
13088
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 37296 times.
41958 for(auto q = 0; q < 8; ++q)
13089 {
13090
2/4
✓ Branch 0 taken 37296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37296 times.
✗ Branch 3 not taken.
37296 if(!p_getc(&temp_meta.initd_type[q],f))
13091 return qe_invalid;
13092 37296 }
13093
13094
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 script->meta = temp_meta;
13095
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4662 times.
4662 }
13096
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if(!p_igetl(&script->pc, f))
13097 return qe_invalid;
13098
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if(!p_igetl(&script->end_pc, f))
13099 return qe_invalid;
13100
13101
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if (script == &fake_script_data)
13102 return 0;
13103
13104
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 assert(zasm_scripts.size() == 1);
13105 4662 auto& zs = zasm_scripts[0];
13106 4662 script->zasm_script = zs;
13107
13108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4662 times.
4662 if (script->valid())
13109 {
13110 4662 zs->script_datas.push_back(script);
13111 4662 read_scripts.push_back(script);
13112 4662 }
13113
13114 4662 return 0;
13115 1067142 }
13116
13117 558546 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13118 {
13119 558546 char b33[34] = {0};
13120 558546 b33[33] = 0;
13121 558546 int32_t num_commands=1000;
13122
13123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558546 times.
558546 if(s_version>=2)
13124 {
13125
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 if(!p_igetl(&num_commands,f))
13126 {
13127 return qe_invalid;
13128 }
13129 558546 }
13130
13131 #ifdef ZC_FUZZ
13132 const int32_t command_limit = 300000;
13133 #else
13134 558546 const int32_t command_limit = 10000000;
13135 #endif
13136
2/4
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 558546 times.
558546 if (num_commands < 0 || num_commands > command_limit)
13137 {
13138 return qe_invalid;
13139 }
13140
13141 558546 std::vector<ffscript> zasm;
13142
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 zasm.reserve(num_commands);
13143
13144
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 308600 times.
558546 if(s_version >= 16)
13145 {
13146
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13147
13148
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13149 {
13150 return qe_invalid;
13151 }
13152
13153
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13154 {
13155 return qe_invalid;
13156 }
13157
13158
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13159 {
13160 return qe_invalid;
13161 }
13162
13163
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13164 {
13165 return qe_invalid;
13166 }
13167
13168
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13169 {
13170
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13171 {
13172
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13173 {
13174
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13175 {
13176 return qe_invalid;
13177 }
13178 4748040 }
13179
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13180 143880 }
13181 else
13182 {
13183
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13184 {
13185 return qe_invalid;
13186 }
13187 }
13188 1999568 }
13189
13190
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13191 {
13192
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13193 {
13194 return qe_invalid;
13195 }
13196 1999568 }
13197
13198
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13199 {
13200 return qe_invalid;
13201 }
13202
13203
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13204 {
13205 return qe_invalid;
13206 }
13207
13208
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13209 {
13210 return qe_invalid;
13211 }
13212
13213
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13214 {
13215 return qe_invalid;
13216 }
13217
13218
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13219 {
13220 return qe_invalid;
13221 }
13222
13223
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13224 {
13225
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13226 {
13227
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13228 {
13229 return qe_invalid;
13230 }
13231 593505 }
13232
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13233
13234
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13235 {
13236
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13237 {
13238 return qe_invalid;
13239 }
13240 593505 }
13241
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13242 17985 }
13243
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13244 {
13245
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13246 return qe_invalid;
13247
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13248 return qe_invalid;
13249 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13250
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13251 {
13252
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13253 return qe_invalid;
13254
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13255 return qe_invalid;
13256 2319610 }
13257
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13258 {
13259
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13260 return qe_invalid;
13261
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13262 return qe_invalid;
13263 1855688 }
13264
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13265 {
13266
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13267 return qe_invalid;
13268
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13269 return qe_invalid;
13270 1855688 }
13271
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13272 {
13273
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13274 return qe_invalid;
13275
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13276 return qe_invalid;
13277 3711376 }
13278 231961 }
13279
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13280 {
13281
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13282 {
13283
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13284 return qe_invalid;
13285
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13286 return qe_invalid;
13287 1855688 }
13288
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13289 {
13290
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13291 return qe_invalid;
13292 1855688 }
13293 231961 }
13294 else
13295 {
13296
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13297 {
13298
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13299 143880 }
13300 }
13301
13302
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13303
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 308600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308600 times.
✗ Branch 5 not taken.
558546 } else script->meta = {};
13304
13305
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 106040107 times.
106114781 for(int32_t j=0; j<num_commands; j++)
13306 {
13307
1/2
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
106040107 auto& sc = zasm.emplace_back();
13308
2/4
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106040107 times.
✗ Branch 3 not taken.
106040107 if(!p_igetw(&sc.command,f))
13309 {
13310 return qe_invalid;
13311 }
13312
13313
2/2
✓ Branch 0 taken 105556235 times.
✓ Branch 1 taken 483872 times.
106040107 if(sc.command == 0xFFFF)
13314 483872 break;
13315 else
13316 {
13317
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg1,f))
13318 {
13319 return qe_invalid;
13320 }
13321
13322
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg2,f))
13323 {
13324 return qe_invalid;
13325 }
13326
13327
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 104508488 times.
105556235 if(s_version >= 24)
13328
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13329 return qe_invalid;
13330
13331
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 97334198 times.
105556235 if(s_version >= 21)
13332 {
13333 8222037 uint32_t sz = 0;
13334
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13335 {
13336 return qe_invalid;
13337 }
13338
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13339 {
13340
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13341 char dummy;
13342
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13343 {
13344
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13345 {
13346 return qe_invalid;
13347 }
13348
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13349 1165008 }
13350 19400 }
13351
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13352 {
13353 return qe_invalid;
13354 }
13355
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13356 {
13357
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13358 int32_t dummy;
13359
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13360 {
13361
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13362 {
13363 return qe_invalid;
13364 }
13365
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13366 11526 }
13367 933 }
13368 8222037 }
13369 }
13370 105556235 }
13371
13372
2/2
✓ Branch 0 taken 490450 times.
✓ Branch 1 taken 68096 times.
558546 if (script == &fake_script_data)
13373 68096 return 0;
13374
13375 // If the first command is unknown, invalidate the whole thing.
13376 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13377
5/6
✓ Branch 0 taken 421152 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 409175 times.
✓ Branch 3 taken 11977 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 409175 times.
490450 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13378 {
13379 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13380 zasm.clear();
13381 }
13382
13383 490450 zasm_script_id id = zasm_scripts.size();
13384
3/6
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 490450 times.
✗ Branch 5 not taken.
490450 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13385 490450 script->zasm_script = zs;
13386 490450 script->pc = 0;
13387 490450 script->end_pc = zs->size;
13388
3/4
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 478473 times.
490450 if (script->valid())
13389 {
13390
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 zs->script_datas.push_back(script);
13391
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 read_scripts.push_back(script);
13392 11977 }
13393
13394 490450 return 0;
13395 558546 }
13396
13397 extern SAMPLE customsfxdata[WAV_COUNT];
13398 extern uint8_t customsfxflag[WAV_COUNT>>3];
13399 extern int32_t sfxdat;
13400 extern DATAFILE *sfxdata;
13401 const char *old_sfx_string[Z35] =
13402 {
13403 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13404 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13405 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13406 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13407 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13408 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13409 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13410 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13411 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13412 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13413 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13414 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13415 };
13416 char *sfx_string[WAV_COUNT];
13417
13418 398 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13419 {
13420 //these are here to bypass compiler warnings about unused arguments
13421 398 Header=Header;
13422
13423 int32_t dummy;
13424 398 word s_version=0;
13425 //int32_t ret;
13426 398 SAMPLE temp_sample = {};
13427 398 temp_sample.loop_start=0;
13428 398 temp_sample.loop_end=0;
13429 398 temp_sample.param=0;
13430
13431 //section version info
13432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&s_version,f))
13433 {
13434 return qe_invalid;
13435 }
13436
13437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_SFX)
13438 return qe_version;
13439
13440 398 FFCore.quest_format[vSFX] = s_version;
13441
13442
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
13443 {
13444 return qe_invalid;
13445 }
13446
13447 //section size
13448
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
13449 {
13450 return qe_invalid;
13451 }
13452
13453 /* HIGHLY UNORTHODOX UPDATING THING, by L
13454 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13455 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13456 * changing from 1 to 2.
13457 */
13458
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 2)
13459 set_qr(qr_GOTOLESSNOTEQUAL,1);
13460
13461 /* End highly unorthodox updating thing */
13462
13463 398 int32_t wavcount = WAV_COUNT;
13464
13465
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 6)
13466 wavcount = 128;
13467
13468 uint8_t tempflag[WAV_COUNT>>3];
13469
13470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(s_version < 4)
13471 {
13472 memset(tempflag, 0xFF, WAV_COUNT>>3);
13473 }
13474 else
13475 {
13476
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version < 6)
13477 memset(tempflag, 0, WAV_COUNT>>3);
13478
13479
2/2
✓ Branch 0 taken 12736 times.
✓ Branch 1 taken 398 times.
13134 for(int32_t i=0; i<(wavcount>>3); i++)
13480 {
13481 12736 p_getc(&tempflag[i], f);
13482 12736 }
13483
13484 }
13485
13486
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(s_version>4)
13487 {
13488
2/2
✓ Branch 0 taken 101490 times.
✓ Branch 1 taken 398 times.
101888 for(int32_t i=1; i<WAV_COUNT; i++)
13489 {
13490 101490 sprintf(sfx_string[i],"s%03d",i);
13491
13492
2/2
✓ Branch 0 taken 77610 times.
✓ Branch 1 taken 23880 times.
101490 if((i<Z35))
13493 23880 strcpy(sfx_string[i], old_sfx_string[i-1]);
13494
13495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101490 times.
101490 if(i>=wavcount)
13496 continue;
13497
2/2
✓ Branch 0 taken 20870 times.
✓ Branch 1 taken 80620 times.
101490 if(get_bit(tempflag, i-1))
13498 {
13499 char tempname[36];
13500
13501
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!pfread(tempname, 36, f))
13502 {
13503 return qe_invalid;
13504 }
13505
13506 20870 sfx_string[i][0] = '\0';
13507 20870 strncat(sfx_string[i], tempname, 36 - 1);
13508 20870 }
13509 else
13510 {
13511 80620 sprintf(sfx_string[i],"s%03d",i);
13512
13513
2/2
✓ Branch 0 taken 70930 times.
✓ Branch 1 taken 9690 times.
80620 if(i<Z35)
13514 9690 strcpy(sfx_string[i], old_sfx_string[i-1]);
13515 80620 sfx_string[i][35] = 0; //Force NULL Termination
13516 }
13517 101490 }
13518 398 }
13519 else
13520 {
13521 for(int32_t i=1; i<WAV_COUNT; i++)
13522 {
13523 sprintf(sfx_string[i],"s%03d",i);
13524
13525 if(i<Z35)
13526 strcpy(sfx_string[i], old_sfx_string[i-1]);
13527 }
13528 }
13529
13530 //finally... section data
13531
2/2
✓ Branch 0 taken 101490 times.
✓ Branch 1 taken 398 times.
101888 for(int32_t i=1; i<wavcount; i++)
13532 {
13533
2/2
✓ Branch 0 taken 20870 times.
✓ Branch 1 taken 80620 times.
101490 if(get_bit(tempflag, i-1))
13534 {
13535
13536
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13537 {
13538 return qe_invalid;
13539 }
13540
13541 20870 (temp_sample.bits) = dummy;
13542
13543
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13544 {
13545 return qe_invalid;
13546 }
13547
13548 20870 (temp_sample.stereo) = dummy;
13549
13550
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13551 {
13552 return qe_invalid;
13553 }
13554
13555 20870 (temp_sample.freq) = dummy;
13556
13557
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&dummy,f))
13558 {
13559 return qe_invalid;
13560 }
13561
13562 20870 (temp_sample.priority) = dummy;
13563
13564
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.len),f))
13565 {
13566 return qe_invalid;
13567 }
13568
13569
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.loop_start),f))
13570 {
13571 return qe_invalid;
13572 }
13573
13574
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.loop_end),f))
13575 {
13576 return qe_invalid;
13577 }
13578
13579
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(!p_igetl(&(temp_sample.param),f))
13580 {
13581 return qe_invalid;
13582 }
13583
13584 20870 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13585 #ifdef ZC_FUZZ
13586 const int32_t sfx_limit = 100000;
13587 if (len < 0 || len > sfx_limit)
13588 {
13589 return qe_invalid;
13590 }
13591 #endif
13592 20870 temp_sample.data = calloc(len,1);
13593
13594
1/2
✓ Branch 0 taken 20870 times.
✗ Branch 1 not taken.
20870 if(s_version < 3)
13595 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13596
13597 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20870 times.
20870 if(s_version < 2)
13599 {
13600 if(!pfread(temp_sample.data, len,f))
13601 {
13602 return qe_invalid;
13603 }
13604 }
13605 else
13606 {
13607 //re-endianfy the data
13608 20870 int32_t wordstoread = len / sizeof(word);
13609
13610
2/2
✓ Branch 0 taken 574262528 times.
✓ Branch 1 taken 20870 times.
574283398 for(int32_t j=0; j<wordstoread; j++)
13611 {
13612 word temp;
13613
13614
1/2
✓ Branch 0 taken 574262528 times.
✗ Branch 1 not taken.
574262528 if(!p_igetw(&temp, f))
13615 {
13616 return qe_invalid;
13617 }
13618
13619 574262528 ((word *)temp_sample.data)[j] = temp;
13620 574262528 }
13621 }
13622 20870 }
13623
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 70930 times.
80620 else if(i < Z35)
13624 {
13625 9690 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13626 9690 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13627 9690 set_bit(tempflag, i-1, 1);
13628 9690 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13629 9690 temp_sample.data = calloc(len,1);
13630 9690 memcpy(temp_sample.data, datsamp->data, len);
13631 9690 }
13632 70930 else continue;
13633
13634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30560 times.
30560 if(customsfxdata[i].data!=NULL)
13635 {
13636 // delete [] customsfxdata[i].data;
13637 30560 free(customsfxdata[i].data);
13638 30560 }
13639
13640 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13641 30560 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13642 30560 customsfxdata[i].data = calloc(len2,1);
13643 30560 customsfxdata[i].bits = temp_sample.bits;
13644 30560 customsfxdata[i].stereo = temp_sample.stereo;
13645 30560 customsfxdata[i].freq = temp_sample.freq;
13646 30560 customsfxdata[i].priority = temp_sample.priority;
13647 30560 customsfxdata[i].len = temp_sample.len;
13648 30560 customsfxdata[i].loop_start = temp_sample.loop_start;
13649 30560 customsfxdata[i].loop_end = temp_sample.loop_end;
13650 30560 customsfxdata[i].param = temp_sample.param;
13651 30560 int32_t cpylen = len2;
13652
13653
1/2
✓ Branch 0 taken 30560 times.
✗ Branch 1 not taken.
30560 if(s_version<3)
13654 {
13655 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13656 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13657 }
13658
13659 30560 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13660
13661 30560 free(temp_sample.data);
13662 30560 }
13663
13664 398 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13665
13666 398 sfxdat=0;
13667 398 return 0;
13668 398 }
13669
13670 480 void setupsfx()
13671 {
13672
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=1; i<WAV_COUNT; i++)
13673 {
13674 122400 sprintf(sfx_string[i],"s%03d",i);
13675
13676
2/2
✓ Branch 0 taken 93600 times.
✓ Branch 1 taken 28800 times.
122400 if(i<Z35)
13677 {
13678 28800 strcpy(sfx_string[i], old_sfx_string[i-1]);
13679 28800 }
13680
13681 122400 memset(customsfxflag, 0, WAV_COUNT>>3);
13682
13683 122400 int32_t j=i;
13684
13685
2/2
✓ Branch 0 taken 29280 times.
✓ Branch 1 taken 93120 times.
122400 if(i>Z35)
13686 {
13687 93120 i=Z35;
13688 93120 }
13689
13690 122400 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13691
13692
2/2
✓ Branch 0 taken 94605 times.
✓ Branch 1 taken 27795 times.
122400 if(customsfxdata[j].data!=NULL)
13693 {
13694 // delete [] customsfxdata[j].data;
13695 27795 free(customsfxdata[j].data);
13696 27795 }
13697
13698 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13699 122400 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13700 122400 customsfxdata[j].bits = temp_sample->bits;
13701 122400 customsfxdata[j].stereo = temp_sample->stereo;
13702 122400 customsfxdata[j].freq = temp_sample->freq;
13703 122400 customsfxdata[j].priority = temp_sample->priority;
13704 122400 customsfxdata[j].len = temp_sample->len;
13705 122400 customsfxdata[j].loop_start = temp_sample->loop_start;
13706 122400 customsfxdata[j].loop_end = temp_sample->loop_end;
13707 122400 customsfxdata[j].param = temp_sample->param;
13708 122400 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13709 122400 i=j;
13710 122400 }
13711 480 }
13712
13713 extern char *guy_string[eMAXGUYS];
13714 extern const char *old_guy_string[OLDMAXGUYS];
13715
13716 480 int32_t readguys(PACKFILE *f, zquestheader *Header)
13717 {
13718
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (should_skip) return 0;
13720
13721 dword dummy;
13722 word guy_cversion;
13723 480 word guyversion=0;
13724
13725
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version >= 0x193)
13726 {
13727 //section version info
13728
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&guyversion,f))
13729 {
13730 return qe_invalid;
13731 }
13732
13733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (guyversion > V_GUYS)
13734 return qe_version;
13735
13736 457 FFCore.quest_format[vGuys] = guyversion;
13737
13738 // Note: this is the only instance where "cversion" is ever used.
13739
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&guy_cversion,f))
13740 {
13741 return qe_invalid;
13742 }
13743
13744 //section size
13745
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
13746 {
13747 return qe_invalid;
13748 }
13749 457 }
13750
13751
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(guyversion > 3)
13752 {
13753
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 398 times.
204174 for(int32_t i=0; i<MAXGUYS; i++)
13754 {
13755 char tempname[64];
13756
13757 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13758 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13760 {
13761 memset(tempname, 0, sizeof(char)*64);
13762 sprintf(tempname, "e%03d", i);
13763 strcpy(guy_string[i], tempname);
13764
13765 continue;
13766 }
13767
13768
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!pfread(tempname, 64, f))
13769 {
13770 return qe_invalid;
13771 }
13772
13773 // Don't retain names of uneditable enemy entries!
13774 // for version upgrade to 2.5
13775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(guyversion < 23 && i >= 177)
13776 {
13777 // some of the older builds have names such as 'zz123',
13778 // (this order gets messed up with some eXXX and some zzXXX)
13779 // so let's update to the newer naming convection. -Gleeok
13780 char tmpbuf[64];
13781 memset(tmpbuf, 0, sizeof(char)*64);
13782 sprintf(tmpbuf, "zz%03d", i);
13783
13784 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13785 {
13786 memset(tempname, 0, sizeof(char)*64);
13787 sprintf(tempname, "e%03d", i);
13788 }
13789 }
13790
13791
6/6
✓ Branch 0 taken 70446 times.
✓ Branch 1 taken 133330 times.
✓ Branch 2 taken 66864 times.
✓ Branch 3 taken 3582 times.
✓ Branch 4 taken 58274 times.
✓ Branch 5 taken 8590 times.
203776 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13792 {
13793 195186 guy_string[i][0] = '\0';
13794 195186 strncat(guy_string[i], tempname, 64 - 1);
13795 195186 }
13796 else
13797 {
13798 8590 strcpy(guy_string[i],old_guy_string[i]);
13799 }
13800 203776 }
13801 398 }
13802 else
13803 {
13804
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13805 {
13806 41984 sprintf(guy_string[i],"zz%03d",i);
13807 41984 }
13808
13809
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13810 {
13811 14514 strcpy(guy_string[i],old_guy_string[i]);
13812 14514 }
13813 }
13814
13815
13816 //finally... section data
13817 480 init_guys(guyversion); //using default data for now...
13818
13819 // Goriya guy fix
13820
3/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13821 {
13822
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13823 {
13824 60 guysbuf[gGORIYA].tile=130;
13825 60 guysbuf[gGORIYA].e_tile=130;
13826 60 }
13827 82 }
13828
13829
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if(Header->zelda_version < 0x193)
13830 {
13831
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13832 {
13833 5 guysbuf[eDODONGO].cset=14;
13834 5 guysbuf[eDODONGO].bosspal=spDIG;
13835 5 }
13836 23 }
13837 // Not sure when this first changed, but it's necessary for 2.10, at least
13838 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13839 //2.10 Fixes
13840
3/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13841 {
13842 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13843 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13844 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13845 82 guysbuf[eCENT1].attributes[2] = 1;
13846 82 guysbuf[eCENT2].attributes[2] = 1;
13847 82 }
13848
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
480 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13849 {
13850 480 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13851 480 }
13852
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if(Header->zelda_version <= 0x210)
13853 {
13854 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13855 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13856 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13857 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13858
13859 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13860 82 guysbuf[eBATROBE].attributes[3] = 1;
13861 //guysbuf[eSUMMONER].misc4 = 1;
13862 82 guysbuf[eWWIZ].attributes[3] = 1;
13863 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13864 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13865 82 }
13866
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 12 times.
480 if(Header->zelda_version == 0x190)
13867 {
13868 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13869 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13870 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13871 12 }
13872
13873 // The versions here may not be correct
13874 // zelda_version>=0x211 handled at guyversion<24
13875
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 462 times.
480 if(Header->zelda_version <= 0x190)
13876 {
13877 18 guysbuf[eCENT1].attributes[2] = 0;
13878 18 guysbuf[eCENT2].attributes[2] = 0;
13879 18 guysbuf[eMOLDORM].attributes[1] = 0;
13880 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13881 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13882 18 }
13883
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 64 times.
462 else if(Header->zelda_version <= 0x210)
13884 {
13885 64 guysbuf[eCENT1].attributes[2] = 1;
13886 64 guysbuf[eCENT2].attributes[2] = 1;
13887 64 guysbuf[eMOLDORM].attributes[1] = 0;
13888 64 }
13889
13890
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 82 times.
480 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13891 {
13892 82 guysbuf[eKEESE1].attributes[15] = 120;
13893 82 guysbuf[eKEESE2].attributes[15] = 120;
13894 82 guysbuf[eKEESE3].attributes[15] = 120;
13895 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13896 82 guysbuf[eKEESE1].attributes[16] = 16;
13897 82 guysbuf[eKEESE2].attributes[16] = 16;
13898 82 guysbuf[eKEESE3].attributes[16] = 16;
13899 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13900
13901 82 guysbuf[ePEAHAT].attributes[15] = 80;
13902 82 guysbuf[ePEAHAT].attributes[16] = 16;
13903
13904 82 guysbuf[eGHINI2].attributes[15] = 120;
13905 82 guysbuf[eGHINI2].attributes[16] = 10;
13906
13907
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13908 {
13909 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13910 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13911 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13912 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13913 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13914 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13915 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13916 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13917 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13918 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13919 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13920 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13921 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13922 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13923 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13924 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13925 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13926 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13927 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13928 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13929 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13930 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13931 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13932 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13933 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13934 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13935 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13936 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13937 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13938 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13939 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13940 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13941 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13942 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13943 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13944 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13945 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13946 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13947 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13948 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13949 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13950 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13951 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13952 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13953 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13954 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13955 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13956 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13957 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13958 66 }
13959 82 }
13960
13961
13962
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 398 times.
480 if(guyversion<=2)
13963 {
13964 82 return readherosprites2(f, guyversion==2?0:-1);
13965 }
13966
13967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(guyversion > 3)
13968 {
13969 398 guydata tempguy;
13970
13971
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 398 times.
204174 for(int32_t i=0; i<MAXGUYS; i++)
13972 {
13973
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 23) // May 2012 : 512 max enemies
13974 {
13975 if(i >= OLDBETAMAXGUYS)
13976 {
13977 guysbuf[i].clear();
13978 continue;
13979 }
13980 }
13981
13982 203776 tempguy.clear();
13983
13984 uint32_t flags1;
13985 uint32_t flags2;
13986
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(flags1),f))
13987 {
13988 return qe_invalid;
13989 }
13990
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(flags2),f))
13991 {
13992 return qe_invalid;
13993 }
13994 203776 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13995
13996
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion >= 36 ) //expanded tiles
13997 {
13998
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.tile),f))
13999 {
14000 return qe_invalid;
14001 }
14002 101376 }
14003 else
14004 {
14005
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.tile),f))
14006 {
14007 return qe_invalid;
14008 }
14009 }
14010
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.width),f))
14011 {
14012 return qe_invalid;
14013 }
14014
14015
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.height),f))
14016 {
14017 return qe_invalid;
14018 }
14019
14020
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion >= 36 ) //expanded tiles
14021 {
14022
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.s_tile),f))
14023 {
14024 return qe_invalid;
14025 }
14026 101376 }
14027 else
14028 {
14029
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.s_tile),f))
14030 {
14031 return qe_invalid;
14032 }
14033 }
14034
14035
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.s_width),f))
14036 {
14037 return qe_invalid;
14038 }
14039
14040
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.s_height),f))
14041 {
14042 return qe_invalid;
14043 }
14044
14045
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion >= 36 ) //expanded tiles
14046 {
14047
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.e_tile),f))
14048 {
14049 return qe_invalid;
14050 }
14051 101376 }
14052 else
14053 {
14054
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.e_tile),f))
14055 {
14056 return qe_invalid;
14057 }
14058 }
14059
14060
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.e_width),f))
14061 {
14062 return qe_invalid;
14063 }
14064
14065
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.e_height),f))
14066 {
14067 return qe_invalid;
14068 }
14069
14070
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.hp),f))
14071 {
14072 return qe_invalid;
14073 }
14074
14075
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.type),f))
14076 {
14077 return qe_invalid;
14078 }
14079
14080
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
203776 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14081 {
14082 if(get_qr(qr_NEWENEMYTILES))
14083 {
14084 tempguy.s_tile=tempguy.e_tile+120;
14085 tempguy.s_width=tempguy.e_width;
14086 tempguy.s_height=tempguy.e_height;
14087 }
14088 else tempguy.s_tile=860;
14089 }
14090
14091
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.cset),f))
14092 {
14093 return qe_invalid;
14094 }
14095
14096
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.anim),f))
14097 {
14098 return qe_invalid;
14099 }
14100
14101
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.e_anim),f))
14102 {
14103 return qe_invalid;
14104 }
14105
14106
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.frate),f))
14107 {
14108 return qe_invalid;
14109 }
14110
14111
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.e_frate),f))
14112 {
14113 return qe_invalid;
14114 }
14115
14116
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 13) // April 2009
14117 {
14118 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14119 {
14120 tempguy.frate *= 2;
14121 tempguy.e_frate *= 2;
14122 }
14123 }
14124
14125
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 14) // May 1 2009
14126 {
14127 if(tempguy.anim==a2FRMSLOW)
14128 {
14129 tempguy.anim=a2FRM;
14130 tempguy.frate *= 2;
14131 }
14132
14133 if(tempguy.e_anim==a2FRMSLOW)
14134 {
14135 tempguy.e_anim=a2FRM;
14136 tempguy.e_frate *= 2;
14137 }
14138
14139 if(tempguy.anim==aFLIPSLOW)
14140 {
14141 tempguy.anim=aFLIP;
14142 tempguy.frate *= 2;
14143 }
14144
14145 if(tempguy.e_anim==aFLIPSLOW)
14146 {
14147 tempguy.e_anim=aFLIP;
14148 tempguy.e_frate *= 2;
14149 }
14150
14151 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14152
14153 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14154
14155 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14156 {
14157 tempguy.anim=a4FRM4DIR;
14158 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14159 }
14160
14161 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14162 {
14163 tempguy.e_anim=a4FRM4DIR;
14164 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14165 }
14166 }
14167
14168
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.dp),f))
14169 {
14170 return qe_invalid;
14171 }
14172
14173 //correction for guy fire
14174
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 6)
14175 {
14176 if(i == gFIRE)
14177 tempguy.dp = 2;
14178 }
14179
14180
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.wdp),f))
14181 {
14182 return qe_invalid;
14183 }
14184
14185
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.weapon),f))
14186 {
14187 return qe_invalid;
14188 }
14189
14190 //correction for bosses using triple, "rising" fireballs
14191
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 5)
14192 {
14193 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14194 i == eGOHMA3 || i == eGOHMA4)
14195 {
14196 if(tempguy.weapon == ewFireball)
14197 tempguy.weapon = ewFireball2;
14198 }
14199 }
14200
14201
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.rate),f))
14202 {
14203 return qe_invalid;
14204 }
14205
14206
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.hrate),f))
14207 {
14208 return qe_invalid;
14209 }
14210
14211
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.step),f))
14212 {
14213 return qe_invalid;
14214 }
14215
14216 // HIGHLY UNORTHODOX UPDATING THING, part 2
14217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203776 if(fixpolsvoice && tempguy.type==eePOLSV)
14218 {
14219 tempguy.step /= 2;
14220 }
14221
14222
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.homing),f))
14223 {
14224 return qe_invalid;
14225 }
14226
14227
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.grumble),f))
14228 {
14229 return qe_invalid;
14230 }
14231
14232
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.item_set),f))
14233 {
14234 return qe_invalid;
14235 }
14236
14237
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14238 {
14239
2/2
✓ Branch 0 taken 2037760 times.
✓ Branch 1 taken 203776 times.
2241536 for (int q = 0; q < 10; ++q)
14240 {
14241
1/2
✓ Branch 0 taken 2037760 times.
✗ Branch 1 not taken.
2037760 if (!p_igetl(&(tempguy.attributes[q]), f))
14242 {
14243 return qe_invalid;
14244 }
14245 2037760 }
14246 203776 }
14247 else
14248 {
14249 int16_t tempMisc;
14250
14251 for(int q=0;q<10;q++)
14252 {
14253 if (!p_igetw(&tempMisc, f))
14254 {
14255 return qe_invalid;
14256 }
14257 tempguy.attributes[q] = tempMisc;
14258 }
14259
14260 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14261 {
14262 if(tempguy.type == eeWIZZ && !(tempguy.attributes[0]))
14263 tempguy.attributes[4] = 74;
14264 }
14265
14266 }
14267
14268
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.bgsfx),f))
14269 {
14270 return qe_invalid;
14271 }
14272
14273
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.bosspal),f))
14274 {
14275 return qe_invalid;
14276 }
14277
14278
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetw(&(tempguy.extend),f))
14279 {
14280 return qe_invalid;
14281 }
14282
14283 //! Enemy Defences
14284
14285 //If a 2.50 quest, use only the 2.5 defences.
14286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14287 {
14288
2/2
✓ Branch 0 taken 3871744 times.
✓ Branch 1 taken 203776 times.
4075520 for(int32_t j=0; j<edefLAST; j++)
14289 {
14290
1/2
✓ Branch 0 taken 3871744 times.
✗ Branch 1 not taken.
3871744 if(!p_getc(&(tempguy.defense[j]),f))
14291 {
14292 return qe_invalid;
14293 }
14294 3871744 }
14295 //then copy the generic script defence to all the new script defences
14296
14297 203776 }
14298
14299
14300
14301
14302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203776 times.
203776 if(guyversion >= 18)
14303 {
14304
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.hitsfx),f))
14305 {
14306 return qe_invalid;
14307 }
14308
14309
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_getc(&(tempguy.deadsfx),f))
14310 {
14311 return qe_invalid;
14312 }
14313 203776 }
14314
14315
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion >= 22)
14316 {
14317
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(tempguy.attributes[10]), f))
14318 {
14319 return qe_invalid;
14320 }
14321
14322
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(!p_igetl(&(tempguy.attributes[11]),f))
14323 {
14324 return qe_invalid;
14325 }
14326 203776 }
14327 else if(guyversion >= 19)
14328 {
14329 int16_t tempMisc;
14330
14331 if(!p_igetw(&tempMisc,f))
14332 {
14333 return qe_invalid;
14334 }
14335
14336 tempguy.attributes[10] = tempMisc;
14337
14338 if(!p_igetw(&tempMisc,f))
14339 {
14340 return qe_invalid;
14341 }
14342
14343 tempguy.attributes[11] = tempMisc;
14344 }
14345
14346 //If a 2.54 or later quest, use all of the defences.
14347
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 24) // Add new guyversion conditional statement
14348 {
14349
2/2
✓ Branch 0 taken 2230272 times.
✓ Branch 1 taken 101376 times.
2331648 for(int32_t j=edefLAST; j<edefLAST255; j++)
14350 {
14351
1/2
✓ Branch 0 taken 2230272 times.
✗ Branch 1 not taken.
2230272 if(!p_getc(&(tempguy.defense[j]),f))
14352 {
14353 return qe_invalid;
14354 }
14355 2230272 }
14356 101376 }
14357
14358
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14359 {
14360
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14361 {
14362 1024000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14363 1024000 }
14364 102400 }
14365
14366 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14367
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 25)
14368 {
14369
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.txsz),f))
14370 {
14371 return qe_invalid;
14372 }
14373
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.tysz),f))
14374 {
14375 return qe_invalid;
14376 }
14377
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hxsz),f))
14378 {
14379 return qe_invalid;
14380 }
14381
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hysz),f))
14382 {
14383 return qe_invalid;
14384 }
14385
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hzsz),f))
14386 {
14387 return qe_invalid;
14388 }
14389 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14390
14391 */
14392 101376 }
14393 //More Enemy Editor vars for 2.60
14394
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 26)
14395 {
14396
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hxofs),f))
14397 {
14398 return qe_invalid;
14399 }
14400
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.hyofs),f))
14401 {
14402 return qe_invalid;
14403 }
14404
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.xofs),f))
14405 {
14406 return qe_invalid;
14407 }
14408
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.yofs),f))
14409 {
14410 return qe_invalid;
14411 }
14412
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.zofs),f))
14413 {
14414 return qe_invalid;
14415 }
14416 101376 }
14417
14418
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14419 {
14420 102400 tempguy.wpnsprite = 0;
14421 102400 }
14422
14423
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 27)
14424 {
14425
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.wpnsprite),f))
14426 {
14427 return qe_invalid;
14428 }
14429 101376 }
14430
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14431 {
14432 102400 tempguy.SIZEflags = 0;
14433 102400 }
14434
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion > 28)
14435 {
14436
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.SIZEflags),f))
14437 {
14438 return qe_invalid;
14439 }
14440
14441 101376 }
14442
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14443 {
14444 102400 tempguy.frozentile = 0;
14445 102400 tempguy.frozencset = 0;
14446 102400 tempguy.frozenclock = 0;
14447
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14448 102400 }
14449
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 30)
14450 {
14451
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.frozentile),f))
14452 {
14453 return qe_invalid;
14454 }
14455
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.frozencset),f))
14456 {
14457 return qe_invalid;
14458 }
14459
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.frozenclock),f))
14460 {
14461 return qe_invalid;
14462 }
14463
2/2
✓ Branch 0 taken 1013760 times.
✓ Branch 1 taken 101376 times.
1115136 for ( int32_t q = 0; q < 10; q++ ) {
14464
1/2
✓ Branch 0 taken 1013760 times.
✗ Branch 1 not taken.
1013760 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14465 {
14466 return qe_invalid;
14467 }
14468 1013760 }
14469
14470 101376 }
14471
14472
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 34)
14473 {
14474
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetw(&(tempguy.firesfx),f))
14475 {
14476 return qe_invalid;
14477 }
14478
2/2
✓ Branch 0 taken 1723392 times.
✓ Branch 1 taken 101376 times.
1824768 for(int q=15;q<32;++q)
14479 {
14480
1/2
✓ Branch 0 taken 1723392 times.
✗ Branch 1 not taken.
1723392 if(!p_igetl(&(tempguy.attributes[q]),f))
14481 {
14482 return qe_invalid;
14483 }
14484 1723392 }
14485
14486
2/2
✓ Branch 0 taken 3244032 times.
✓ Branch 1 taken 101376 times.
3345408 for ( int32_t q = 0; q < 32; q++ ) {
14487
1/2
✓ Branch 0 taken 3244032 times.
✗ Branch 1 not taken.
3244032 if(!p_igetl(&(tempguy.movement[q]),f))
14488 {
14489 return qe_invalid;
14490 }
14491 3244032 }
14492
2/2
✓ Branch 0 taken 3244032 times.
✓ Branch 1 taken 101376 times.
3345408 for ( int32_t q = 0; q < 32; q++ ) {
14493
1/2
✓ Branch 0 taken 3244032 times.
✗ Branch 1 not taken.
3244032 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14494 {
14495 return qe_invalid;
14496 }
14497 3244032 }
14498
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetw(&(tempguy.script),f))
14499 {
14500 return qe_invalid;
14501 }
14502
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
14503 {
14504
1/2
✓ Branch 0 taken 811008 times.
✗ Branch 1 not taken.
811008 if(!p_igetl(&(tempguy.initD[q]),f))
14505 {
14506 return qe_invalid;
14507 }
14508 811008 }
14509
2/2
✓ Branch 0 taken 202752 times.
✓ Branch 1 taken 101376 times.
304128 for ( int32_t q = 0; q < 2; q++ )
14510 {
14511 int32_t temp;
14512
1/2
✓ Branch 0 taken 202752 times.
✗ Branch 1 not taken.
202752 if(!p_igetl(&temp,f))
14513 {
14514 return qe_invalid;
14515 }
14516 202752 }
14517
14518 101376 }
14519
14520
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 37)
14521 {
14522
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.editorflags),f))
14523 {
14524 return qe_invalid;
14525 }
14526 101376 }
14527
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14528
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if(guyversion >= 38)
14529 {
14530
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.attributes[12]),f))
14531 {
14532 return qe_invalid;
14533 }
14534
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.attributes[13]),f))
14535 {
14536 return qe_invalid;
14537 }
14538
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_igetl(&(tempguy.attributes[14]),f))
14539 {
14540 return qe_invalid;
14541 }
14542
14543 101376 }
14544
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 38 )
14545 {
14546 102400 tempguy.attributes[12] = 0;
14547 102400 tempguy.attributes[13] = 0;
14548 102400 tempguy.attributes[14] = 0;
14549 102400 }
14550
14551
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if ( guyversion >= 39 )
14552 {
14553
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 101376 times.
912384 for ( int32_t q = 0; q < 8; q++ )
14554 {
14555
2/2
✓ Branch 0 taken 52715520 times.
✓ Branch 1 taken 811008 times.
53526528 for ( int32_t w = 0; w < 65; w++ )
14556 {
14557
1/2
✓ Branch 0 taken 52715520 times.
✗ Branch 1 not taken.
52715520 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14558 {
14559 return qe_invalid;
14560 }
14561 52715520 }
14562
2/2
✓ Branch 0 taken 528384 times.
✓ Branch 1 taken 282624 times.
811008 if(guyversion < 54)
14563 {
14564 byte dummybyte;
14565
2/2
✓ Branch 0 taken 18370560 times.
✓ Branch 1 taken 282624 times.
18653184 for ( int32_t w = 0; w < 65; w++ )
14566
1/2
✓ Branch 0 taken 18370560 times.
✗ Branch 1 not taken.
18370560 if(!p_getc(&dummybyte,f))
14567 return qe_invalid;
14568 282624 }
14569 811008 }
14570
14571
14572 101376 }
14573
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 39 ) //apply old InitD strings to both
14574 {
14575
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ )
14576 {
14577 819200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14578 819200 }
14579 102400 }
14580
4/4
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 66048 times.
✓ Branch 3 taken 35328 times.
203776 if ( guyversion >= 40 && guyversion < 54)
14581
1/2
✓ Branch 0 taken 35328 times.
✗ Branch 1 not taken.
35328 if(!p_igetw(&(tempguy.weap_data.script),f))
14582 return qe_invalid;
14583
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if ( guyversion < 40 )
14584 102400 tempguy.weap_data.script = 0;
14585 //eweapon script InitD
14586
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
203776 if ( guyversion >= 41 )
14587 {
14588
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 35328 times.
101376 if(guyversion < 54)
14589
2/2
✓ Branch 0 taken 282624 times.
✓ Branch 1 taken 35328 times.
317952 for ( int32_t q = 0; q < 8; q++ )
14590
1/2
✓ Branch 0 taken 282624 times.
✗ Branch 1 not taken.
282624 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14591 35328 return qe_invalid;
14592
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if ( guy_cversion < 4 )
14593 {
14594 if ( tempguy.type == eeKEESE )
14595 {
14596
14597 if ( !tempguy.attributes[0] )
14598 {
14599 tempguy.attributes[15] = 120;
14600 tempguy.attributes[16] = 16;
14601
14602 }
14603 }
14604 if ( tempguy.type == eePEAHAT )
14605 {
14606 tempguy.attributes[15] = 80;
14607 tempguy.attributes[16] = 16;
14608 }
14609
14610 if ( tempguy.type == eeGHINI )
14611 {
14612 tempguy.attributes[15] = 120;
14613 tempguy.attributes[16] = 10;
14614 }
14615
14616 }
14617 101376 }
14618
14619
14620
14621 //default weapon sprites (quest version < 2.54)
14622 //port over old defaults -Z
14623
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 32)
14624 {
14625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.wpnsprite <= 0 )
14626 {
14627
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14628 {
14629 case wNone:
14630 86878 tempguy.wpnsprite = 0; break;
14631
14632 case wSword:
14633 case wBeam:
14634 case wBrang:
14635 case wBomb:
14636 case wSBomb:
14637 case wLitBomb:
14638 case wLitSBomb:
14639 case wArrow:
14640 case wFire:
14641 case wWhistle:
14642 case wBait:
14643 case wWand:
14644 case wMagic:
14645 case wCatching:
14646 case wWind:
14647 case wRefMagic:
14648 case wRefFireball:
14649 case wRefRock:
14650 case wHammer:
14651 case wHookshot:
14652 case wHSHandle:
14653 case wHSChain:
14654 case wSSparkle:
14655 case wFSparkle:
14656 case wSmack:
14657 case wPhantom:
14658 case wCByrna:
14659 case wRefBeam:
14660 case wStomp:
14661 case lwMax:
14662 case wScript1:
14663 case wScript2:
14664 case wScript3:
14665 case wScript4:
14666 case wScript5:
14667 case wScript6:
14668 case wScript7:
14669 case wScript8:
14670 case wScript9:
14671 case wScript10:
14672 case wIce:
14673 //Cannot use any of these weapons yet.
14674 tempguy.wpnsprite = -1;
14675 break;
14676
14677 case wEnemyWeapons:
14678 2849 case ewFireball: tempguy.wpnsprite = 17; break;
14679
14680 801 case ewArrow: tempguy.wpnsprite = 19; break;
14681 691 case ewBrang: tempguy.wpnsprite = 4; break;
14682 1900 case ewSword: tempguy.wpnsprite = 20; break;
14683 1291 case ewRock: tempguy.wpnsprite = 18; break;
14684 2399 case ewMagic: tempguy.wpnsprite = 21; break;
14685 206 case ewBomb: tempguy.wpnsprite = 78; break;
14686 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14687 448 case ewLitBomb: tempguy.wpnsprite = 76; break;
14688 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14689 906 case ewFireTrail: tempguy.wpnsprite = 80; break;
14690 1802 case ewFlame: tempguy.wpnsprite = 35; break;
14691 229 case ewWind: tempguy.wpnsprite = 36; break;
14692 325 case ewFlame2: tempguy.wpnsprite = 81; break;
14693 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14694 case ewIce: tempguy.wpnsprite = 83; break;
14695 1519 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14696
14697
14698 default: break; //No assign.
14699 }
14700 102400 }
14701 102400 }
14702
14703 //default weapon fire sound (quest version < 2.54)
14704 //port over old defaults and zero new data. -Z
14705
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 34)
14706 {
14707
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 102400 times.
3379200 for ( int32_t q = 0; q < 32; q++ )
14708 {
14709 3276800 tempguy.movement[q] = 0;
14710 3276800 tempguy.new_weapon[q] = 0;
14711
14712 3276800 }
14713
14714 //NPC Script attributes.
14715 102400 tempguy.script = 0; //No scripted enemies existed. -Z
14716
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14717
14718
2/2
✓ Branch 0 taken 1740800 times.
✓ Branch 1 taken 102400 times.
1843200 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14719
14720 //old default sounds
14721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.firesfx <= 0 )
14722 {
14723
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14724 {
14725 case wNone:
14726 86878 tempguy.firesfx = 0; break;
14727
14728 case wSword:
14729 case wBeam:
14730 case wBrang:
14731 case wBomb:
14732 case wSBomb:
14733 case wLitBomb:
14734 case wLitSBomb:
14735 case wArrow:
14736 case wFire:
14737 case wWhistle:
14738 case wBait:
14739 case wWand:
14740 case wMagic:
14741 case wCatching:
14742 case wWind:
14743 case wRefMagic:
14744 case wRefFireball:
14745 case wRefRock:
14746 case wHammer:
14747 case wHookshot:
14748 case wHSHandle:
14749 case wHSChain:
14750 case wSSparkle:
14751 case wFSparkle:
14752 case wSmack:
14753 case wPhantom:
14754 case wCByrna:
14755 case wRefBeam:
14756 case wStomp:
14757 case lwMax:
14758 case wScript1:
14759 case wScript2:
14760 case wScript3:
14761 case wScript4:
14762 case wScript5:
14763 case wScript6:
14764 case wScript7:
14765 case wScript8:
14766 case wScript9:
14767 case wScript10:
14768 case wIce:
14769 //Cannot use any of these weapons yet.
14770 tempguy.firesfx = -1;
14771 break;
14772
14773 case wEnemyWeapons:
14774 2849 case ewFireball: tempguy.firesfx = 40; break;
14775
14776 801 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14777 691 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14778 1900 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14779 1291 case ewRock: tempguy.firesfx = 51; break;
14780 2399 case ewMagic: tempguy.firesfx = 32; break;
14781 206 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14782 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14783 448 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14784 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14785 906 case ewFireTrail: tempguy.firesfx = 13; break;
14786 1802 case ewFlame: tempguy.firesfx = 13; break;
14787 229 case ewWind: tempguy.firesfx = 32; break;
14788 325 case ewFlame2: tempguy.firesfx = 13; break;
14789 case ewFlame2Trail: tempguy.firesfx = 13; break;
14790 case ewIce: tempguy.firesfx = 44; break;
14791 1519 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14792
14793 //what about special attacks (e.g. summoning == 56)
14794 default: break; //No assign.
14795 }
14796 102400 }
14797 102400 }
14798
14799 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14800
4/6
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 101376 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 101376 times.
203776 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14801 {
14802
2/2
✓ Branch 0 taken 89799 times.
✓ Branch 1 taken 12601 times.
102400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14803 102400 }
14804 //Keese and bat halt rates.
14805
3/4
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 101376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102400 times.
203776 if ( guyversion < 42 && guy_cversion < 4 )
14806 {
14807
14808
2/2
✓ Branch 0 taken 101101 times.
✓ Branch 1 taken 1299 times.
102400 if ( tempguy.type == eeKEESE )
14809 {
14810
14811
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 364 times.
1299 if ( !tempguy.attributes[0] )
14812 {
14813 935 tempguy.attributes[15] = 120;
14814 935 tempguy.attributes[16] = 16;
14815
14816 935 }
14817 1299 }
14818
2/2
✓ Branch 0 taken 101935 times.
✓ Branch 1 taken 465 times.
102400 if ( tempguy.type == eePEAHAT )
14819 {
14820 465 tempguy.attributes[15] = 80;
14821 465 tempguy.attributes[16] = 16;
14822 465 }
14823
2/2
✓ Branch 0 taken 102200 times.
✓ Branch 1 taken 200 times.
102400 if ( tempguy.type == eeGHINI )
14824 {
14825 200 tempguy.attributes[15] = 120;
14826 200 tempguy.attributes[16] = 10;
14827 200 }
14828
14829
14830 102400 }
14831
14832
14833 //miscellaneous other corrections
14834 //fix the mirror wizzrobe -DD
14835
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 7)
14836 {
14837 if(i == eMWIZ)
14838 {
14839 tempguy.attributes[1] = 0;
14840 tempguy.attributes[3] = 1;
14841 }
14842 }
14843
14844
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 8)
14845 {
14846 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14847 {
14848 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14849 tempguy.attributes[4] = 4; //neck length in segments
14850 tempguy.attributes[5] = 8; //neck offset from first body tile
14851 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14852 tempguy.attributes[7] = 168; //head offset from first body tile
14853 tempguy.attributes[8] = 228; //flying head offset from first body tile
14854
14855 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14856 {
14857 tempguy.attributes[5] += 10; //neck offset from first body tile
14858 tempguy.attributes[7] -= 12; //head offset from first body tile
14859 }
14860 }
14861 }
14862
14863
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14864 {
14865 if(get_bit(deprecated_rules,46) && tempguy.type==eeDONGO && tempguy.attributes[0]==0)
14866 tempguy.bosspal = spDIG;
14867 }
14868
14869
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 11) // December 2007 - Spinning Tile fix
14870 {
14871 if(tempguy.type==eeSPINTILE)
14872 {
14873 tempguy.flags |= guy_superman;
14874 tempguy.item_set = 0; // Don't drop items
14875 tempguy.step = 300;
14876 }
14877 }
14878
14879
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14880 {
14881 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14882 {
14883 if(tempguy.type==eeROPE)
14884 {
14885 tempguy.flags &= ~guy_flashing;
14886 }
14887 }
14888
14889 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14890 {
14891 if(tempguy.type==eeBUBBLE)
14892 {
14893 tempguy.flags &= ~guy_flashing;
14894 }
14895 }
14896
14897 if((tempguy.type==eeGHINI)&&(tempguy.attributes[0]))
14898 {
14899 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14900 {
14901 tempguy.flags |= guy_blinking;
14902 }
14903
14904 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14905 {
14906 tempguy.flags |= guy_transparent;
14907 }
14908 }
14909 }
14910
14911
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14912 {
14913 if(i==gFIRE)
14914 {
14915 tempguy.e_anim = aFLIP;
14916 tempguy.e_frate = 24;
14917 }
14918
14919 if(i==gFAIRY)
14920 {
14921 tempguy.e_anim = a2FRM;
14922 tempguy.e_frate = 16;
14923 }
14924 }
14925
14926
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14927 {
14928 if(i==0) Z_message("Updating guys to version 16...\n");
14929
14930 update_guy_1(&tempguy);
14931
14932 if(i==eMPOLSV)
14933 {
14934 tempguy.defense[edefARROW] = edCHINK;
14935 tempguy.defense[edefMAGIC] = ed1HKO;
14936 tempguy.defense[edefREFMAGIC] = ed1HKO;
14937 }
14938 }
14939
14940
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 17) // December 2009
14941 {
14942 if(tempguy.type==eePROJECTILE)
14943 {
14944 tempguy.attributes[0] = 0;
14945 }
14946 }
14947
14948
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 18) // January 2010
14949 {
14950 bool boss = (tempguy.type == eeAQUA || tempguy.type==eeDONGO || tempguy.type == eeMANHAN || tempguy.type == eeGHOMA || tempguy.type==eeDIG
14951 || tempguy.type == eeGLEEOK || tempguy.type==eePATRA || tempguy.type == eeGANON || tempguy.type==eeMOLD);
14952
14953 tempguy.hitsfx = (boss && tempguy.type != eeMOLD && tempguy.type != eeDONGO && tempguy.type != eeDIG) ? WAV_GASP : 0;
14954 tempguy.deadsfx = (boss && (tempguy.type != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14955
14956 if(tempguy.type == eeAQUA)
14957 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14958 else if(tempguy.type == eeMANHAN)
14959 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14960 else if(tempguy.type==eePATRA)
14961 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14962 else if(tempguy.type==eeGHOMA)
14963 {
14964 for(int32_t j=0; j<edefLAST; j++)
14965 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14966
14967 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14968
14969 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14970
14971 tempguy.attributes[0]--;
14972 }
14973 else if(tempguy.type == eeGLEEOK)
14974 {
14975 for(int32_t j=0; j<edefLAST; j++)
14976 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14977
14978 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14979 }
14980 else if(tempguy.type == eeARMOS)
14981 {
14982 tempguy.type=eeWALK;
14983 tempguy.hrate = 0;
14984 tempguy.attributes[9] = tempguy.attributes[0];
14985 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14986 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14987 tempguy.attributes[8] = e9tARMOS;
14988 }
14989 else if(tempguy.type == eeGHINI && !tempguy.attributes[0])
14990 {
14991 tempguy.type=eeWALK;
14992 tempguy.hrate = 0;
14993 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14994 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14995 }
14996
14997 // Spawn animation flags
14998 if(tempguy.type == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14999 tempguy.flags |= guy_fade_flicker;
15000 else
15001 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
15002 }
15003
15004
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 20) // April 2010
15005 {
15006 if(tempguy.type == eeTRAP)
15007 {
15008 tempguy.attributes[1] = tempguy.attributes[9];
15009
15010 if(tempguy.attributes[9]>=1)
15011 {
15012 tempguy.attributes[0]++;
15013 }
15014
15015 tempguy.attributes[9] = 0;
15016 }
15017
15018 // Bomb Blast fix
15019 if(tempguy.weapon==ewBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15020 tempguy.weapon = ewLitBomb;
15021 else if(tempguy.weapon==ewSBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15022 tempguy.weapon = ewLitSBomb;
15023 }
15024
15025
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 21) // September 2011
15026 {
15027 if(tempguy.type == eeKEESE || tempguy.type == eeKEESETRIB)
15028 {
15029 if(tempguy.type == eeKEESETRIB)
15030 {
15031 tempguy.type = eeKEESE;
15032 tempguy.attributes[1] = e2tKEESETRIB;
15033 tempguy.attributes[0] = 0;
15034 }
15035
15036 tempguy.rate = 2;
15037 tempguy.hrate = 8;
15038 tempguy.homing = 0;
15039 tempguy.step= (tempguy.type == eeKEESE && tempguy.attributes[0] ? 100:62);
15040 }
15041 else if(tempguy.type == eePEAHAT || tempguy.type==eePATRA)
15042 {
15043 if(tempguy.type == eePEAHAT)
15044 {
15045 tempguy.rate = 4;
15046 tempguy.step = 62;
15047 }
15048 else
15049 tempguy.step = 25;
15050
15051 tempguy.hrate = 8;
15052 tempguy.homing = 0;
15053 }
15054 else if(tempguy.type == eeDIG || tempguy.type == eeMANHAN)
15055 {
15056 if(tempguy.type == eeMANHAN)
15057 tempguy.step=50;
15058
15059 tempguy.hrate = 16;
15060 tempguy.homing = 0;
15061 }
15062 else if(tempguy.type == eeGLEEOK)
15063 {
15064 tempguy.rate = 2;
15065 tempguy.homing = 0;
15066 tempguy.hrate = 9;
15067 tempguy.step=89;
15068 }
15069 else if(tempguy.type == eeGHINI)
15070 {
15071 tempguy.rate = 4;
15072 tempguy.hrate = 12;
15073 tempguy.step=62;
15074 tempguy.homing = 0;
15075 }
15076
15077 // Bigdig random rate fix
15078 if(tempguy.type==eeDIG && tempguy.attributes[9]==1)
15079 {
15080 tempguy.rate = 2;
15081 }
15082 }
15083
15084
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(guyversion < 24) // November 2012
15085 {
15086 if(tempguy.type==eeLANM)
15087 tempguy.attributes[2] = 1;
15088 else if(tempguy.type==eeMOLD)
15089 tempguy.attributes[1] = 0;
15090 }
15091
15092
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15093 {
15094
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 101000 times.
102400 if(tempguy.type!=eeDIG)
15095 {
15096 101000 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15097 101000 }
15098
15099 102400 }
15100 // does not seem to solve the issue!
15101
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if ( Header->zelda_version <= 0x210 )
15102 {
15103 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15104 if ( tempguy.type == eeDONGO )
15105 {
15106 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15107 }
15108 }
15109
15110
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion >= 42)
15111 {
15112
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 2560 times.
101376 if(guyversion >= 47)
15113 {
15114
1/2
✓ Branch 0 taken 98816 times.
✗ Branch 1 not taken.
98816 if(!p_igetl(&(tempguy.moveflags),f))
15115 {
15116 return qe_invalid;
15117 }
15118 98816 }
15119 else
15120 {
15121 byte fl;
15122
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15123 {
15124 return qe_invalid;
15125 }
15126 2560 tempguy.moveflags = (move_flags)fl;
15127 }
15128 101376 }
15129 else
15130 {
15131
7/8
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 80670 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 642 times.
✓ Branch 6 taken 498 times.
✓ Branch 7 taken 13859 times.
102400 switch(tempguy.type)
15132 {
15133 //No gravity; floats over pits
15134 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15135 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15136 //Special (bosses, etc)
15137 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15138 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15139 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15140 80670 tempguy.moveflags = move_can_pitwalk;
15141 80670 break;
15142 //No gravity, but falls in pits
15143 case eeLEV:
15144 958 tempguy.moveflags = move_can_pitfall;
15145 958 break;
15146 //Bosses that respect pits
15147 case eeDONGO:
15148 642 tempguy.moveflags = move_obeys_grav;
15149 642 break;
15150 case eeLANM:
15151 498 tempguy.moveflags = move_none;
15152 498 break;
15153 //Gravity, floats over pits
15154 case eeWIZZ: case eeWALLM: case eeGHINI:
15155 2717 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15156 2717 break;
15157 //Gravity and falls in pits
15158 case eeWALK:
15159
4/4
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12635 times.
13859 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15160 1224 break;
15161 [[fallthrough]];
15162 case eeOTHER:
15163 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15164 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15165 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15166 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15167 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15168 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15169 15691 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15170 15691 }
15171 }
15172
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 43)
15173 {
15174
2/2
✓ Branch 0 taken 83387 times.
✓ Branch 1 taken 19013 times.
102400 switch(tempguy.type)
15175 {
15176 //No gravity; floats over pits
15177 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15178 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15179 //Special (bosses, etc)
15180 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15181 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15182 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15183 case eeWIZZ: case eeWALLM: case eeGHINI:
15184 //Gravity, floats over pits
15185 83387 tempguy.moveflags |= move_can_waterwalk;
15186 83387 tempguy.moveflags |= move_can_pitwalk;
15187 83387 break;
15188 }
15189 102400 }
15190
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if (guyversion < 44)
15191 {
15192
2/2
✓ Branch 0 taken 101487 times.
✓ Branch 1 taken 913 times.
102400 if ( tempguy.type == eeGHOMA )
15193 {
15194 913 tempguy.flags |= guy_fade_instant;
15195 913 }
15196 102400 }
15197
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if (guyversion > 44)
15198 {
15199
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&(tempguy.spr_shadow),f))
15200 {
15201 return qe_invalid;
15202 }
15203
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&(tempguy.spr_death),f))
15204 {
15205 return qe_invalid;
15206 }
15207
1/2
✓ Branch 0 taken 101376 times.
✗ Branch 1 not taken.
101376 if(!p_getc(&(tempguy.spr_spawn),f))
15208 {
15209 return qe_invalid;
15210 }
15211 101376 }
15212 else
15213 {
15214
2/2
✓ Branch 0 taken 102003 times.
✓ Branch 1 taken 397 times.
102400 tempguy.spr_shadow = (tempguy.type==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15215 102400 tempguy.spr_death = iwDeath;
15216 102400 tempguy.spr_spawn = iwSpawn;
15217 }
15218
15219
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 102400 times.
203776 if(guyversion < 46)
15220 {
15221
4/4
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 88541 times.
✓ Branch 2 taken 13164 times.
✓ Branch 3 taken 695 times.
102400 if(tempguy.type == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15222 {
15223 695 tempguy.moveflags |= move_can_waterwalk;
15224 695 }
15225 102400 }
15226
15227
2/2
✓ Branch 0 taken 98816 times.
✓ Branch 1 taken 104960 times.
203776 if (guyversion < 47)
15228 {
15229
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 574 times.
104960 if (tempguy.type == eeDIG && tempguy.attributes[9]!=1)
15230 {
15231 574 tempguy.flags |= guy_ignore_kill_all;
15232 574 }
15233 104960 }
15234
15235
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 125440 times.
203776 if (guyversion < 49)
15236 {
15237
8/8
✓ Branch 0 taken 16388 times.
✓ Branch 1 taken 109052 times.
✓ Branch 2 taken 15916 times.
✓ Branch 3 taken 472 times.
✓ Branch 4 taken 15433 times.
✓ Branch 5 taken 483 times.
✓ Branch 6 taken 528 times.
✓ Branch 7 taken 14905 times.
125440 if (tempguy.type == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15238 {
15239
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 712 times.
✓ Branch 3 taken 61 times.
1483 switch (tempguy.attributes[7]) {
15240 case 0: //Sword
15241 710 tempguy.attributes[7] = e8tSWORD;
15242 710 break;
15243 case 1: //Item
15244 712 tempguy.attributes[7] = e8tITEM;
15245 712 break;
15246 case 2: //Both
15247 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15248 61 break;
15249 default: //this can actually happen since Misc8 can be set to any number.
15250 tempguy.attributes[7] = 0;
15251 break;
15252 }
15253 1483 }
15254 125440 }
15255
15256 //these could possible be combined but rather be safe...
15257
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 125440 times.
203776 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15258 {
15259 125440 guy_update_firesfx(tempguy);
15260 125440 }
15261
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 78336 times.
203776 if (guyversion < 52)
15262 {
15263 125440 guy_update_weaponflags(tempguy);
15264 125440 }
15265
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 12288 times.
78336 else if(guyversion < 54)
15266 {
15267
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15268 return qe_invalid;
15269
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15270 return qe_invalid;
15271
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15272 return qe_invalid;
15273
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15274 return qe_invalid;
15275
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15276 return qe_invalid;
15277
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15278 return qe_invalid;
15279
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15280 return qe_invalid;
15281
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15282 return qe_invalid;
15283
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15284 return qe_invalid;
15285
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15286 return qe_invalid;
15287
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15288 return qe_invalid;
15289
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15290 return qe_invalid;
15291 int32_t temp_step;
15292
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if (!p_igetl(&temp_step, f))
15293 return qe_invalid;
15294 12288 tempguy.weap_data.step = zslongToFix(temp_step*100);
15295
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 12288 times.
73728 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15296 {
15297
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15298 return qe_invalid;
15299
1/2
✓ Branch 0 taken 61440 times.
✗ Branch 1 not taken.
61440 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15300 return qe_invalid;
15301 61440 }
15302 12288 }
15303
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 78336 times.
203776 if (guyversion < 53)
15304 {
15305 125440 guy_update_weaponspecialsfx(tempguy);
15306 125440 }
15307 else
15308 {
15309
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if (!p_getc(&(tempguy.specialsfx), f))
15310 return qe_invalid;
15311 }
15312
15313
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 137728 times.
203776 if(guyversion >= 54)
15314 {
15315
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(auto ret = read_weap_data(tempguy.weap_data, f))
15316 return ret;
15317 66048 }
15318 else
15319 {
15320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137728 times.
137728 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15321 137728 tempguy.weap_data.flags |= wdata_set_step;
15322
2/2
✓ Branch 0 taken 136057 times.
✓ Branch 1 taken 1671 times.
137728 if(tempguy.weapon == ewRock)
15323 1671 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15324 }
15325
15326
1/2
✓ Branch 0 taken 203776 times.
✗ Branch 1 not taken.
203776 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15327 {
15328 tempguy.script = 0;
15329 for(int q = 0; q < 8; ++q)
15330 tempguy.initD[q] = 0;
15331 }
15332 203776 guysbuf[i] = tempguy;
15333 203776 }
15334 398 }
15335
15336 398 return 0;
15337 480 }
15338
15339 void update_guy_1(guydata *tempguy) // November 2009
15340 {
15341 bool doesntcount = false;
15342 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15343
15344 switch(tempguy->type)
15345 {
15346 case 1: //eeWALK
15347 switch(tempguy->attributes[9])
15348 {
15349 case 0: //Stalfos
15350 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15351 tempguy->attributes[0]=4;
15352
15353 break;
15354
15355 case 1: //Darknut
15356 goto darknuts;
15357 break;
15358 }
15359
15360 tempguy->attributes[9] = 0;
15361 break;
15362
15363 case 2: //eeSHOOT
15364 tempguy->type = eeWALK;
15365
15366 switch(tempguy->attributes[9])
15367 {
15368 case 0: //Octorok
15369 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15370 {
15371 tempguy->attributes[0]=e1tFIREOCTO;
15372 tempguy->attributes[1]=e2tFIREOCTO;
15373 }
15374 else tempguy->attributes[0] = 0;
15375
15376 tempguy->attributes[5]=tempguy->attributes[3];
15377 tempguy->attributes[3]=tempguy->attributes[2];
15378 tempguy->attributes[2]=0;
15379 break;
15380
15381 case 1: // Moblin
15382 tempguy->attributes[0] = 0;
15383 break;
15384
15385 case 2: //Lynel
15386 tempguy->attributes[5]=tempguy->attributes[0]+1;
15387 tempguy->attributes[0]=0;
15388 break;
15389
15390 case 3: //Stalfos 2
15391 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15392 tempguy->attributes[0]=e1t4SHOTS;
15393 else tempguy->attributes[0] = 0;
15394
15395 break;
15396
15397 case 4: //Darknut 5
15398 darknuts:
15399 tempguy->defense[edefFIRE] = edIGNORE;
15400 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15401 tempguy->defense[edefHOOKSHOT] = 0;
15402 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15403 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15404
15405 if(tempguy->attributes[0]==1)
15406 tempguy->attributes[0]=2;
15407 else if(tempguy->attributes[0]==2)
15408 {
15409 tempguy->attributes[3]=tempguy->attributes[2];
15410 tempguy->attributes[2]=tempguy->attributes[1];
15411 tempguy->attributes[1]=e2tSPLIT;
15412 tempguy->attributes[0] = 0;
15413 }
15414 else tempguy->attributes[0] = 0;
15415
15416 tempguy->flags |= guy_shield_front;
15417
15418 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15419 tempguy->flags &= ~guy_bkshield;
15420 else
15421 tempguy->flags |= guy_bkshield;
15422
15423 break;
15424 }
15425
15426 tempguy->attributes[9] = 0;
15427 break;
15428
15429 /*
15430 case 9: //eeARMOS
15431 tempguy->family = eeWALK;
15432 break;
15433 */
15434 case 11: //eeGEL
15435 case 33: //eeGELTRIB
15436 if(tempguy->type==33)
15437 {
15438 tempguy->attributes[3] = 1;
15439
15440 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15441 tempguy->attributes[2] = tempguy->attributes[1];
15442
15443 tempguy->attributes[1] = e2tTRIBBLE;
15444 }
15445 else
15446 {
15447 tempguy->attributes[3] = 0;
15448 tempguy->attributes[2] = 0;
15449 tempguy->attributes[1] = 0;
15450 }
15451
15452 tempguy->type = eeWALK;
15453
15454 if(tempguy->attributes[0])
15455 {
15456 tempguy->attributes[0]=1;
15457 tempguy->weapon = ewFireTrail;
15458 }
15459
15460 break;
15461
15462 case 34: //eeZOLTRIB
15463 case 12: //eeZOL
15464 tempguy->attributes[3]=tempguy->attributes[2];
15465 tempguy->attributes[2]=tempguy->attributes[1];
15466 tempguy->type = eeWALK;
15467 tempguy->attributes[1]=e2tSPLITHIT;
15468
15469 if(tempguy->attributes[0])
15470 {
15471 tempguy->attributes[0]=1;
15472 tempguy->weapon = ewFireTrail;
15473 }
15474
15475 break;
15476
15477 case 13: //eeROPE
15478 tempguy->type = eeWALK;
15479 tempguy->attributes[8] = e9tROPE;
15480
15481 if(tempguy->attributes[0])
15482 {
15483 tempguy->attributes[3] = tempguy->attributes[2];
15484 tempguy->attributes[2] = tempguy->attributes[1];
15485 tempguy->attributes[1] = e2tBOMBCHU;
15486 }
15487
15488 tempguy->attributes[0] = 0;
15489 break;
15490
15491 case 14: //eeGORIYA
15492 tempguy->type = eeWALK;
15493
15494 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15495
15496 break;
15497
15498 case 17: //eeBUBBLE
15499 tempguy->type = eeWALK;
15500 tempguy->attributes[7] = tempguy->attributes[1];
15501 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15502 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15503
15504 //fallthrogh
15505 case eeTRAP:
15506 case eeROCK:
15507 doesntcount = true;
15508 break;
15509
15510 case 35: //eeVIRETRIB
15511 case 18: //eeVIRE
15512 tempguy->type = eeWALK;
15513 tempguy->attributes[3]=tempguy->attributes[2];
15514 tempguy->attributes[2]=tempguy->attributes[1];
15515 tempguy->attributes[1]=e2tSPLITHIT;
15516 tempguy->attributes[8]=e9tVIRE;
15517 break;
15518
15519 case 19: //eeLIKE
15520 tempguy->type = eeWALK;
15521 tempguy->attributes[6] = e7tEATITEMS;
15522 tempguy->attributes[7]=95;
15523 break;
15524
15525 case 20: //eePOLSV
15526 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15527 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15528 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15529 tempguy->defense[edefARROW] = ed1HKO;
15530 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15531 tempguy->type = eeWALK;
15532 tempguy->attributes[8] = e9tPOLSVOICE;
15533 tempguy->rate = 4;
15534 tempguy->homing = 32;
15535 tempguy->hrate = 10;
15536 tempguy->grumble = 0;
15537 break;
15538
15539 case eeWIZZ:
15540 if(tempguy->attributes[3])
15541 {
15542 for(int32_t i=0; i < edefLAST; i++)
15543 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15544 }
15545 else
15546 {
15547 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15548 tempguy->defense[edefMAGIC] = edCHINK;
15549 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15550 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15551 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15552 }
15553
15554 break;
15555
15556 case eePEAHAT:
15557 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15558
15559 if(!(tempguy->flags & guy_bhit))
15560 tempguy->defense[edefBRANG] = edSTUNONLY;
15561
15562 break;
15563
15564 case eeLEV:
15565 tempguy->defense[edefSTOMP] = edCHINK;
15566 break;
15567 }
15568
15569 // Old flags
15570 if(tempguy->flags & guy_superman)
15571 {
15572 for(int32_t i = 0; i < edefLAST; i++)
15573 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15574 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15575 && tempguy->type != eeROCK && tempguy->type != eeTRAP
15576 && tempguy->type != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15577 }
15578
15579 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15580
15581 if(doesntcount)
15582 tempguy->flags |= (guy_doesnt_count);
15583 }
15584
15585 1178856 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15586 {
15587 1178856 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15588
15589 byte tempbyte, padding;
15590 word wpadding;
15591 int32_t extras, secretcombos;
15592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->valid),f))
15593 {
15594 return qe_invalid;
15595 }
15596
15597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->guy),f))
15598 return qe_invalid;
15599 1178856 temp_mapscr->guytile = -1; //signal to use default guy values
15600
2/2
✓ Branch 0 taken 1178256 times.
✓ Branch 1 taken 600 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15601
4/4
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1178256 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 538 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15602
15603
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15604 {
15605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15606 {
15607 return qe_invalid;
15608 }
15609
15610 22176 temp_mapscr->str=tempbyte;
15611 22176 }
15612 else
15613 {
15614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->str),f))
15615 {
15616 return qe_invalid;
15617 }
15618 }
15619
15620
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->room),f))
15621 {
15622 return qe_invalid;
15623 }
15624
15625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->item),f))
15626 {
15627 return qe_invalid;
15628 }
15629
15630
3/6
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 650352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15631 {
15632 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15633 528504 }
15634 else
15635 {
15636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->hasitem),f))
15637 return qe_invalid;
15638 }
15639
15640
3/4
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1181576 if((Header->zelda_version < 0x192)||
15641
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15642 {
15643
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15644 {
15645 return qe_invalid;
15646 }
15647 22176 }
15648
15649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15650 {
15651 return qe_invalid;
15652 }
15653
15654
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15655 {
15656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15657 {
15658 return qe_invalid;
15659 }
15660 24896 }
15661
15662
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15663 {
15664
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15665 {
15666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15667 {
15668 return qe_invalid;
15669 }
15670 1951056 }
15671 650352 }
15672 else
15673 {
15674 528504 temp_mapscr->tilewarptype[1]=0;
15675 528504 temp_mapscr->tilewarptype[2]=0;
15676 528504 temp_mapscr->tilewarptype[3]=0;
15677 }
15678
15679
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15680 {
15681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15682 {
15683 return qe_invalid;
15684 }
15685 1156680 }
15686
15687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15688 {
15689 return qe_invalid;
15690 }
15691
15692 1178856 temp_mapscr->warpreturnx[1]=0;
15693 1178856 temp_mapscr->warpreturnx[2]=0;
15694 1178856 temp_mapscr->warpreturnx[3]=0;
15695
15696
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15697 {
15698
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15699 {
15700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15701 {
15702 return qe_invalid;
15703 }
15704 1951056 }
15705 650352 }
15706
15707
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15708 {
15709 return qe_invalid;
15710 }
15711
15712 1178856 temp_mapscr->warpreturny[1]=0;
15713 1178856 temp_mapscr->warpreturny[2]=0;
15714 1178856 temp_mapscr->warpreturny[3]=0;
15715
15716
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15717 {
15718
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15719 {
15720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15721 {
15722 return qe_invalid;
15723 }
15724 1951056 }
15725
15726
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(version>=18)
15727 {
15728
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15729 {
15730 return qe_invalid;
15731 }
15732 650352 }
15733 else
15734 {
15735 byte temp;
15736
15737 if(!p_getc(&temp,f))
15738 {
15739 return qe_invalid;
15740 }
15741
15742 temp_mapscr->warpreturnc=temp<<8|temp;
15743 }
15744 650352 }
15745
15746
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->stairx),f))
15747
15748 {
15749 return qe_invalid;
15750 }
15751
15752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->stairy),f))
15753 {
15754 return qe_invalid;
15755 }
15756
15757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemx),f))
15758 {
15759 return qe_invalid;
15760 }
15761
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemy),f))
15763 {
15764 return qe_invalid;
15765 }
15766
15767
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version > 15) // February 2009
15768 {
15769
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->color),f))
15770 {
15771 return qe_invalid;
15772 }
15773 650352 }
15774 else
15775 {
15776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15777 {
15778 return qe_invalid;
15779 }
15780
15781 528504 temp_mapscr->color = (word) tempbyte;
15782 }
15783
15784
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags11),f))
15785 {
15786 return qe_invalid;
15787 }
15788
15789
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15790 {
15791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->door[k]),f))
15792 {
15793 return qe_invalid;
15794
15795 }
15796 4715424 }
15797
15798
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
15799 {
15800
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15801 {
15802 return qe_invalid;
15803 }
15804
15805 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15806
15807
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15808 {
15809 for(int32_t i=1; i<4; i++)
15810 {
15811 if(!p_getc(&(tempbyte),f))
15812 {
15813 return qe_invalid;
15814 }
15815
15816 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15817 }
15818 }
15819 else
15820 {
15821 528504 temp_mapscr->tilewarpdmap[1]=0;
15822 528504 temp_mapscr->tilewarpdmap[2]=0;
15823 528504 temp_mapscr->tilewarpdmap[3]=0;
15824 }
15825 528504 }
15826 else
15827 {
15828
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
15829 {
15830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15831 {
15832 return qe_invalid;
15833 }
15834 2601408 }
15835 }
15836
15837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15838 {
15839 return qe_invalid;
15840 }
15841
15842
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15843 {
15844
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15845 {
15846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15847 {
15848 return qe_invalid;
15849 }
15850 1951056 }
15851 650352 }
15852 else
15853 {
15854 528504 temp_mapscr->tilewarpscr[1]=0;
15855 528504 temp_mapscr->tilewarpscr[2]=0;
15856 528504 temp_mapscr->tilewarpscr[3]=0;
15857 }
15858
15859
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15860 {
15861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15862 {
15863 return qe_invalid;
15864 }
15865 650352 }
15866 else
15867 {
15868 528504 temp_mapscr->tilewarpoverlayflags=0;
15869 }
15870
15871
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->exitdir),f))
15872 {
15873 return qe_invalid;
15874 }
15875
15876
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15877 {
15878
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15879 {
15880 return qe_invalid;
15881 }
15882
15883 24896 }
15884
15885
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15886 {
15887 if(!p_getc(&padding,f))
15888 {
15889 return qe_invalid;
15890 }
15891 }
15892
15893
2/2
✓ Branch 0 taken 11788560 times.
✓ Branch 1 taken 1178856 times.
12967416 for(int32_t k=0; k<10; k++)
15894 {
15895
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15896 {
15897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15898 {
15899 return qe_invalid;
15900 }
15901
15902 221760 temp_mapscr->enemy[k]=tempbyte;
15903
15904 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
15905 // from corrupting when 1.90 saved the quest.
15906 // https://discord.com/channels/876899628556091432/1287580827164737658
15907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
15908 {
15909
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
15910 {
15911 temp_mapscr->enemy[k] = 0;
15912 }
15913 221760 }
15914 221760 }
15915 else
15916 {
15917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11566800 times.
11566800 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15918 {
15919 return qe_invalid;
15920 }
15921 }
15922
15923
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15924 {
15925 //using enumerations here is dangerous
15926 //very easy to break old quests -DD
15927
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15928 {
15929 1342 temp_mapscr->enemy[k]+=5;
15930 1342 }
15931
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15932 {
15933 94 temp_mapscr->enemy[k]+=1;
15934 94 }
15935 221760 }
15936
15937
2/2
✓ Branch 0 taken 6503520 times.
✓ Branch 1 taken 5285040 times.
11788560 if(version < 9)
15938 {
15939
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15940 {
15941 275905 temp_mapscr->enemy[k]+=10;
15942 275905 }
15943 5285040 }
15944 //don't read in any invalid data
15945
2/2
✓ Branch 0 taken 11788110 times.
✓ Branch 1 taken 450 times.
11788560 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15946 {
15947 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15948 450 temp_mapscr->enemy[k] = 0;
15949 450 }
15950 11788560 }
15951
15952
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->pattern),f))
15953 {
15954 return qe_invalid;
15955 }
15956
15957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15958 {
15959 return qe_invalid;
15960 }
15961
15962
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15963 {
15964
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15965 {
15966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15967 {
15968 return qe_invalid;
15969 }
15970 1951056 }
15971 650352 }
15972 else
15973 {
15974 528504 temp_mapscr->sidewarptype[1]=0;
15975 528504 temp_mapscr->sidewarptype[2]=0;
15976 528504 temp_mapscr->sidewarptype[3]=0;
15977 }
15978
15979
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15980 {
15981
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15982 {
15983 return qe_invalid;
15984 }
15985 650352 }
15986 else
15987 {
15988 528504 temp_mapscr->sidewarpoverlayflags=0;
15989 }
15990
15991
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15992 {
15993 return qe_invalid;
15994 }
15995
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15997 {
15998 return qe_invalid;
15999 }
16000
16001
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16002 {
16003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->path[k]),f))
16004 {
16005 return qe_invalid;
16006 }
16007 4715424 }
16008
16009
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
16010 {
16011 return qe_invalid;
16012 }
16013
16014
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16015 {
16016
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 1951056 times.
2601408 for(int32_t i=1; i<4; i++)
16017 {
16018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16019 {
16020 return qe_invalid;
16021 }
16022 1951056 }
16023 650352 }
16024 else
16025 {
16026 528504 temp_mapscr->sidewarpscr[1]=0;
16027 528504 temp_mapscr->sidewarpscr[2]=0;
16028 528504 temp_mapscr->sidewarpscr[3]=0;
16029 }
16030
16031
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
16032 {
16033
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
16034 {
16035 return qe_invalid;
16036 }
16037
16038 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16039
16040
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16041 {
16042 for(int32_t i=1; i<4; i++)
16043 {
16044 if(!p_getc(&(tempbyte),f))
16045 {
16046 return qe_invalid;
16047 }
16048
16049 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16050 }
16051 }
16052 else
16053 {
16054 528504 temp_mapscr->sidewarpdmap[1]=0;
16055 528504 temp_mapscr->sidewarpdmap[2]=0;
16056 528504 temp_mapscr->sidewarpdmap[3]=0;
16057 }
16058 528504 }
16059 else
16060 {
16061
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
16062 {
16063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16064 {
16065 return qe_invalid;
16066 }
16067 2601408 }
16068 }
16069
16070
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16071 {
16072
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16073 {
16074 return qe_invalid;
16075 }
16076 650352 }
16077 528504 else temp_mapscr->sidewarpindex = 0;
16078
16079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_igetw(&(temp_mapscr->undercombo),f))
16080 {
16081 return qe_invalid;
16082 }
16083
16084 1178856 byte old_combo_page = 0;
16085
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16086 {
16087
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16088 {
16089 return qe_invalid;
16090 }
16091
16092
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16093 {
16094 24624 old_combo_pages[scrind] = old_combo_page;
16095 24624 }
16096 24896 }
16097
16098
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16099 {
16100 return qe_invalid;
16101 }
16102
16103
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_igetw(&(temp_mapscr->catchall),f))
16104 {
16105 return qe_invalid;
16106 }
16107
16108
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags),f))
16109 {
16110 return qe_invalid;
16111 }
16112
16113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags2),f))
16114 {
16115 return qe_invalid;
16116 }
16117
16118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags3),f))
16119 {
16120 return qe_invalid;
16121 }
16122
16123
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16124 //if (version>2)
16125 {
16126
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags4),f))
16127 {
16128 return qe_invalid;
16129 }
16130 650352 }
16131
16132
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16133 {
16134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags5),f))
16135 {
16136 return qe_invalid;
16137 }
16138
16139
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16140 return qe_invalid;
16141 650352 temp_mapscr->noreset = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED;
16142
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16143 return qe_invalid;
16144 1300704 temp_mapscr->nocarry = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED |
16145 650352 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16146
16147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(temp_mapscr->flags5&32)
16148 {
16149 temp_mapscr->flags5 &= ~32;
16150 temp_mapscr->noreset |= 48;
16151 }
16152
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(version<8)
16154 {
16155 if(temp_mapscr->noreset&1)
16156 {
16157 temp_mapscr->noreset|=8192;
16158 }
16159
16160 if(temp_mapscr->nocarry&1)
16161 {
16162 temp_mapscr->nocarry|=8192;
16163 temp_mapscr->nocarry&=~1;
16164 }
16165 }
16166 650352 }
16167 else
16168 {
16169 528504 temp_mapscr->flags5 = 0;
16170 528504 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
16171 528504 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
16172 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16173 }
16174
16175
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16176 {
16177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags6),f))
16178 {
16179 return qe_invalid;
16180 }
16181 650352 }
16182
16183
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>5)
16184 {
16185
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags7),f))
16186 {
16187 return qe_invalid;
16188 }
16189
16190
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags8),f))
16191 {
16192 return qe_invalid;
16193 }
16194
16195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags9),f))
16196 {
16197 return qe_invalid;
16198 }
16199
16200
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags10),f))
16201 {
16202 return qe_invalid;
16203 }
16204
16205
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->csensitive),f))
16206 {
16207 return qe_invalid;
16208 }
16209 650352 }
16210 else
16211 {
16212 528504 temp_mapscr->csensitive=1;
16213 }
16214
16215
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<14) // August 2007: screen SFX added
16216 {
16217
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16218 {
16219 994 temp_mapscr->bosssfx=
16220
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16221 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16222 WAV_ROAR;
16223 994 }
16224
16225
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16226 {
16227 170 temp_mapscr->oceansfx=WAV_SEA;
16228 170 }
16229
16230 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16231 ? 0 : WAV_SECRET;
16232
16233 528504 temp_mapscr->flags3 &= ~66; //64|2
16234 528504 temp_mapscr->flags2 &= ~32;
16235 528504 temp_mapscr->flags &= ~136; // 128|8
16236 528504 }
16237 else
16238 {
16239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->oceansfx),f))
16240 {
16241 return qe_invalid;
16242 }
16243
16244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->bosssfx),f))
16245 {
16246 return qe_invalid;
16247 }
16248
16249
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->secretsfx),f))
16250 {
16251 return qe_invalid;
16252 }
16253 }
16254
16255
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<15) // October 2007: another SFX
16256 {
16257 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16258 528504 }
16259 else
16260 {
16261
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16262 {
16263 return qe_invalid;
16264 }
16265 }
16266
16267
16268
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16269 {
16270
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16271 {
16272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16273 {
16274 return qe_invalid;
16275 }
16276 6940080 }
16277
16278
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 6940080 times.
8096760 for(int32_t k=0; k<6; k++)
16279 {
16280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16281 {
16282 return qe_invalid;
16283 }
16284 6940080 }
16285 1156680 }
16286
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16287 {
16288 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16289 {
16290 return qe_invalid;
16291 }
16292
16293 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16294 {
16295 return qe_invalid;
16296 }
16297
16298 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16299 {
16300 return qe_invalid;
16301 }
16302
16303 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16304
16305 {
16306 return qe_invalid;
16307 }
16308 }
16309
16310
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>149))
16311 {
16312
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16313 {
16314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16315 {
16316 return qe_invalid;
16317 }
16318 16320 }
16319
16320
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16321 {
16322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16323 {
16324 return qe_invalid;
16325 }
16326 16320 }
16327
16328
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16329 {
16330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16331 {
16332 return qe_invalid;
16333 }
16334 16320 }
16335
16336
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16337 {
16338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16339 {
16340 return qe_invalid;
16341 }
16342 16320 }
16343
16344
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16345 {
16346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16347 {
16348 return qe_invalid;
16349 }
16350 16320 }
16351
16352
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16353 {
16354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16355 {
16356 return qe_invalid;
16357 }
16358 16320 }
16359 2720 }
16360
16361
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16362 {
16363
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16364 {
16365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16366 {
16367 return qe_invalid;
16368 }
16369 6940080 }
16370 1156680 }
16371
16372
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16373 {
16374
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 if((Header->zelda_version == 0x192)&&(Header->build>153))
16375 {
16376
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16377 {
16378 return qe_invalid;
16379 }
16380 2720 }
16381
16382
1/2
✓ Branch 0 taken 1156680 times.
✗ Branch 1 not taken.
1156680 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16383 {
16384 return qe_invalid;
16385 }
16386 1156680 }
16387
16388
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16389 {
16390 22176 extras=15;
16391 22176 }
16392
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16393 {
16394 extras=11;
16395 }
16396
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16397 {
16398 extras=32;
16399 }
16400
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16401 {
16402 extras=64;
16403 }
16404
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 else if(Header->zelda_version < 0x193)
16405 {
16406 2720 extras=62;
16407 2720 }
16408 else
16409
16410 {
16411 1153960 extras=0;
16412 }
16413
16414
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1178856 times.
1680136 for(int32_t k=0; k<extras; k++)
16415 {
16416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16417 {
16418 return qe_invalid;
16419 }
16420 501280 }
16421
16422
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16423 //if (version>3)
16424 {
16425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->nextmap),f))
16426 {
16427 return qe_invalid;
16428 }
16429
16430
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->nextscr),f))
16431 {
16432 return qe_invalid;
16433 }
16434 650352 }
16435 else
16436 {
16437 528504 temp_mapscr->nextmap=0;
16438 528504 temp_mapscr->nextscr=0;
16439 }
16440
16441
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16442 {
16443 22176 secretcombos=20;
16444 22176 }
16445
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16446 {
16447 secretcombos=256;
16448 }
16449 else
16450 {
16451 1156680 secretcombos=128;
16452 }
16453
16454
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16455 {
16456
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16457 {
16458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16459 {
16460 return qe_invalid;
16461 }
16462
16463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16464 {
16465 443520 temp_mapscr->secretcombo[k]=tempbyte;
16466 443520 }
16467 443520 }
16468 22176 }
16469 else
16470 {
16471
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16472 {
16473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16474 {
16475 return qe_invalid;
16476 }
16477
16478 148055040 }
16479 }
16480
16481
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16482 {
16483
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16484 {
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16486 {
16487 return qe_invalid;
16488 }
16489 148055040 }
16490
16491
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16492 {
16493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16494 {
16495 return qe_invalid;
16496 }
16497 148055040 }
16498 1156680 }
16499
16500
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16501 {
16502 if(!p_getc(&padding,f))
16503 {
16504 return qe_invalid;
16505 }
16506 }
16507
16508
2/2
✓ Branch 0 taken 207478656 times.
✓ Branch 1 taken 1178856 times.
208657512 for(int32_t k=0; k<176; k++)
16509 {
16510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207478656 times.
207478656 if(!p_igetw(&(temp_mapscr->data[k]),f))
16511 {
16512 return qe_invalid;
16513 }
16514 207478656 }
16515
16516
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16517 {
16518 if(!p_getc(&padding,f))
16519 {
16520 return qe_invalid;
16521 }
16522
16523 if(!p_getc(&padding,f))
16524 {
16525 return qe_invalid;
16526 }
16527 }
16528
16529
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16530 {
16531
2/2
✓ Branch 0 taken 203575680 times.
✓ Branch 1 taken 1156680 times.
204732360 for(int32_t k=0; k<176; k++)
16532 {
16533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16534 {
16535 return qe_invalid;
16536 }
16537
16538
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 203096960 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
203575680 if((Header->zelda_version == 0x192)&&(Header->build<24))
16539 {
16540 if(!p_getc(&tempbyte,f))
16541 {
16542 return qe_invalid;
16543 }
16544
16545 if(!p_getc(&tempbyte,f))
16546 {
16547 return qe_invalid;
16548 }
16549
16550 if(!p_getc(&tempbyte,f))
16551 {
16552 return qe_invalid;
16553 }
16554 }
16555 203575680 }
16556 1156680 }
16557
16558
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16559 {
16560
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 203575680 times.
204732360 for(int32_t k=0; k<176; k++)
16561 {
16562
16563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->cset[k]),f))
16564 {
16565 return qe_invalid;
16566 }
16567 203575680 }
16568 1156680 }
16569
16570
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16571 {
16572 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16573 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16574 22176 }
16575
16576
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16577 {
16578 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16579 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16580 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16581 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16582 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16583 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16584 22176 }
16585
16586
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16587 {
16588
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16589 {
16590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16591 {
16592 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16593 {
16594 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16595 }
16596 }
16597 else
16598 {
16599
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16600 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16601 {
16602 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16603 3902976 }
16604
16605 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16606 }
16607
16608 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16609 3902976 }
16610 22176 }
16611
16612 /*if(version>12)
16613 {
16614 if(!p_getc(&(temp_mapscr->scrWidth),f))
16615 {
16616 return qe_invalid;
16617 }
16618 if(!p_getc(&(temp_mapscr->scrHeight),f))
16619 {
16620 return qe_invalid;
16621 }
16622 }*/
16623
16624
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>4)
16625 {
16626
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16627 {
16628 return qe_invalid;
16629 }
16630 650352 }
16631 else
16632 {
16633 528504 temp_mapscr->screen_midi = -1;
16634 }
16635
16636
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>=17)
16637 {
16638
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->lens_layer),f))
16639 {
16640 return qe_invalid;
16641 }
16642 650352 }
16643 else
16644 {
16645 528504 temp_mapscr->lens_layer = llNORMAL;
16646 }
16647
16648
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version>6)
16649 {
16650 dword bits;
16651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_igetl(&bits,f))
16652 {
16653 return qe_invalid;
16654 }
16655
16656 int32_t m;
16657 float tempfloat;
16658 word tempw;
16659 650352 temp_mapscr->ffcCountMarkDirty();
16660 650352 temp_mapscr->ffcs.clear();
16661 650352 temp_mapscr->resizeFFC(std::bit_width(bits));
16662
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 20811264 times.
21461616 for(m=0; m<32; m++)
16663 {
16664
2/2
✓ Branch 0 taken 20536512 times.
✓ Branch 1 taken 274752 times.
20811264 if((bits>>m)&1)
16665 {
16666 274752 ffcdata& tempffc = temp_mapscr->ffcs[m];
16667
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetw(&tempw,f))
16668 {
16669 return qe_invalid;
16670 }
16671 274752 tempffc.data = tempw;
16672
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.cset),f))
16674 {
16675 return qe_invalid;
16676 }
16677
16678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.delay),f))
16679 {
16680 return qe_invalid;
16681 }
16682
16683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version < 9)
16684 {
16685 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16686 {
16687 return qe_invalid;
16688 }
16689
16690 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16691
16692 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16693 {
16694 return qe_invalid;
16695 }
16696
16697 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16698
16699 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16700 {
16701 return qe_invalid;
16702 }
16703
16704 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16705
16706 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16707 {
16708 return qe_invalid;
16709 }
16710
16711 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16712
16713 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16714 {
16715 return qe_invalid;
16716 }
16717
16718 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16719
16720 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16721 {
16722 return qe_invalid;
16723 }
16724
16725 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16726 }
16727 else
16728 {
16729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.x),f))
16730 {
16731 return qe_invalid;
16732 }
16733
16734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.y),f))
16735 {
16736 return qe_invalid;
16737 }
16738
16739
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetzf(&(tempffc.vx),f))
16740 {
16741 return qe_invalid;
16742 }
16743
16744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.vy),f))
16745 {
16746 return qe_invalid;
16747 }
16748
16749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ax),f))
16750 {
16751 return qe_invalid;
16752 }
16753
16754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ay),f))
16755 {
16756 return qe_invalid;
16757 }
16758 }
16759
16760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.link),f))
16761 {
16762 return qe_invalid;
16763 }
16764
16765
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>7)
16766 {
16767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16768 {
16769 return qe_invalid;
16770 }
16771
16772 274752 tempffc.hit_width = (tempbyte&0x3F)+1;
16773 274752 tempffc.txsz = (tempbyte>>6)+1;
16774
16775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16776 {
16777 return qe_invalid;
16778 }
16779
16780 274752 tempffc.hit_height = (tempbyte&0x3F)+1;
16781 274752 tempffc.tysz = (tempbyte>>6)+1;
16782
16783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.flags),f))
16784 {
16785 return qe_invalid;
16786 }
16787 274752 }
16788 else
16789 {
16790 tempffc.hit_width=16;
16791 tempffc.hit_height=16;
16792 tempffc.txsz=1;
16793 tempffc.tysz=1;
16794 tempffc.flags=ffc_none;
16795 }
16796
16797 274752 tempffc.updateSolid();
16798
16799
16800
4/6
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268748 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 268748 times.
274752 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16801 {
16802 tempffc.flags|=ffc_ignoreholdup;
16803 }
16804
16805
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>9)
16806 {
16807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.script),f))
16808 {
16809 return qe_invalid;
16810 }
16811 274752 }
16812 else
16813 {
16814 tempffc.script=0;
16815 }
16816
16817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version>10)
16818 {
16819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[0]),f))
16820 {
16821 return qe_invalid;
16822 }
16823
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[1]),f))
16825 {
16826 return qe_invalid;
16827 }
16828
16829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[2]),f))
16830 {
16831 return qe_invalid;
16832 }
16833
16834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[3]),f))
16835 {
16836 return qe_invalid;
16837 }
16838
16839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[4]),f))
16840 {
16841 return qe_invalid;
16842 }
16843
16844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[5]),f))
16845 {
16846 return qe_invalid;
16847 }
16848
16849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[6]),f))
16850 {
16851 return qe_invalid;
16852 }
16853
16854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[7]),f))
16855 {
16856 return qe_invalid;
16857 }
16858
16859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16860 {
16861 return qe_invalid;
16862 }
16863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16864 {
16865 return qe_invalid;
16866 }
16867 274752 }
16868
16869
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16870 {
16871 tempffc.script = 0;
16872 for(int q = 0; q < 8; ++q)
16873 tempffc.initd[q] = 0;
16874 }
16875
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version <= 11)
16876 {
16877 fixffcs=true;
16878 }
16879 274752 }
16880 20811264 }
16881
16882 650352 temp_mapscr->shrinkToFitFFCs();
16883 650352 }
16884
16885
16886 //add in the new whistle flags
16887
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version<13)
16888 {
16889
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16890 {
16891 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16892 124 }
16893 528504 }
16894
16895 //2.55 starts here
16896
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 19 && Header->zelda_version > 0x253 )
16897 {
16898 // mapscr fields that were never used, so are now removed:
16899 // int32_t npcstrings[10];
16900 // int16_t new_items[10];
16901 // int16_t new_item_x[10];
16902 // int16_t new_item_y[10];
16903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16904 {
16905 return qe_invalid;
16906 }
16907 34408 }
16908
16909
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 20 && Header->zelda_version > 0x253 )
16910 {
16911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16912 {
16913 return qe_invalid;
16914 }
16915
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16916 {
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16918 {
16919 return qe_invalid;
16920 }
16921 275264 }
16922 34408 }
16923
2/2
✓ Branch 0 taken 1144448 times.
✓ Branch 1 taken 34408 times.
1178856 if ( version < 20 )
16924 {
16925 1144448 temp_mapscr->script = 0;
16926
2/2
✓ Branch 0 taken 9155584 times.
✓ Branch 1 taken 1144448 times.
10300032 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16927 1144448 }
16928
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 21 && Header->zelda_version > 0x253 )
16929 {
16930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16931 {
16932 return qe_invalid;
16933 }
16934 34408 }
16935
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 21 )
16936 {
16937 1144448 temp_mapscr->preloadscript = 0;
16938 1144448 }
16939
16940
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16941 {
16942
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16943 {
16944 return qe_invalid;
16945 }
16946
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16947 {
16948 return qe_invalid;
16949 }
16950 34408 }
16951
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 22 )
16952 {
16953 1144448 temp_mapscr->hidelayers = 0;
16954 1144448 temp_mapscr->hidescriptlayers = 0;
16955 1144448 }
16956
16957 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16958 //May be any version before 2.11. -Z
16959 /* --not the roar, the HIT SFX
16960 if ( Header->zelda_version <= 0x210 )
16961 {
16962 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16963 {
16964 temp_mapscr->bosssfx = WAV_ROAR;
16965 }
16966 }
16967 */
16968
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16969 {
16970
1/2
✓ Branch 0 taken 4715424 times.
✗ Branch 1 not taken.
4715424 if(temp_mapscr->door[k] == dNONE)
16971 temp_mapscr->door[k] = dWALL;
16972 4715424 }
16973
16974 1178856 return 0;
16975 1178856 }
16976 1385576 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16977 {
16978
2/2
✓ Branch 0 taken 1178856 times.
✓ Branch 1 taken 206720 times.
1385576 if(version < 23)
16979 {
16980 1178856 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(ret) return ret;
16982 1178856 }
16983 else
16984 {
16985
1/2
✓ Branch 0 taken 206720 times.
✗ Branch 1 not taken.
206720 if(!p_getc(&(temp_mapscr->valid),f))
16986 return qe_invalid;
16987
2/2
✓ Branch 0 taken 106424 times.
✓ Branch 1 taken 100296 times.
206720 if(!(temp_mapscr->valid & mVALID))
16988 {
16989 100296 int map = scrind/MAPSCRS;
16990 100296 int screen = scrind%MAPSCRS;
16991
4/6
✓ Branch 0 taken 93194 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 93194 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 93194 times.
100296 if(version > 25 && scrind > -1 && map < map_infos.size())
16992 {
16993 93194 auto const& mapinf = map_infos[map];
16994 //Empty screen, apply defaults
16995
2/2
✓ Branch 0 taken 559164 times.
✓ Branch 1 taken 93194 times.
652358 for(int q = 0; q < 6; ++q)
16996 {
16997 559164 auto layermap = mapinf.autolayers[q];
16998 559164 temp_mapscr->layermap[q] = layermap;
16999
2/2
✓ Branch 0 taken 543627 times.
✓ Branch 1 taken 15537 times.
559164 if(layermap)
17000 15537 temp_mapscr->layerscreen[q] = screen;
17001 559164 }
17002 93194 temp_mapscr->color = mapinf.autopalette;
17003 93194 }
17004 100296 return 0;
17005 }
17006 uint32_t scr_has_flags;
17007
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_igetl(&scr_has_flags,f))
17008 return qe_invalid;
17009
17010
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 95966 times.
106424 if(scr_has_flags & SCRHAS_ROOMDATA)
17011 {
17012
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_getc(&(temp_mapscr->guy),f))
17013 return qe_invalid;
17014
2/2
✓ Branch 0 taken 95846 times.
✓ Branch 1 taken 120 times.
95966 if(version > 26)
17015 {
17016
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_igetl(&(temp_mapscr->guytile),f))
17017 return qe_invalid;
17018
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_getc(&(temp_mapscr->guycs),f))
17019 return qe_invalid;
17020
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_igetw(&(temp_mapscr->roomflags),f))
17021 return qe_invalid;
17022 95846 }
17023 else
17024 {
17025 120 temp_mapscr->guytile = -1; //signal to use default guy values
17026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17028 }
17029
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_igetw(&(temp_mapscr->str),f))
17030 return qe_invalid;
17031
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_getc(&(temp_mapscr->room),f))
17032 return qe_invalid;
17033
1/2
✓ Branch 0 taken 95966 times.
✗ Branch 1 not taken.
95966 if(!p_igetw(&(temp_mapscr->catchall),f))
17034 return qe_invalid;
17035 95966 }
17036
2/2
✓ Branch 0 taken 104052 times.
✓ Branch 1 taken 2372 times.
106424 if(scr_has_flags & SCRHAS_ITEM)
17037 {
17038
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->item),f))
17039 return qe_invalid;
17040
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->hasitem),f))
17041 return qe_invalid;
17042
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->itemx),f))
17043 return qe_invalid;
17044
1/2
✓ Branch 0 taken 2372 times.
✗ Branch 1 not taken.
2372 if(!p_getc(&(temp_mapscr->itemy),f))
17045 return qe_invalid;
17046 2372 }
17047
2/2
✓ Branch 0 taken 95745 times.
✓ Branch 1 taken 10679 times.
106424 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17048 {
17049
1/2
✓ Branch 0 taken 10679 times.
✗ Branch 1 not taken.
10679 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17050 return qe_invalid;
17051 10679 }
17052
2/2
✓ Branch 0 taken 103938 times.
✓ Branch 1 taken 2486 times.
106424 if(scr_has_flags & SCRHAS_TWARP)
17053 {
17054
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2486 times.
12430 for(int32_t i=0; i<4; i++)
17055 {
17056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9944 times.
9944 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17057 return qe_invalid;
17058 9944 }
17059
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2486 times.
12430 for(int32_t i=0; i<4; i++)
17060 {
17061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9944 times.
9944 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17062 return qe_invalid;
17063 9944 }
17064
2/2
✓ Branch 0 taken 9944 times.
✓ Branch 1 taken 2486 times.
12430 for(int32_t i=0; i<4; i++)
17065 {
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9944 times.
9944 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17067 return qe_invalid;
17068 9944 }
17069
1/2
✓ Branch 0 taken 2486 times.
✗ Branch 1 not taken.
2486 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17070 return qe_invalid;
17071 2486 }
17072
2/2
✓ Branch 0 taken 97756 times.
✓ Branch 1 taken 8668 times.
106424 if(scr_has_flags & SCRHAS_SWARP)
17073 {
17074
2/2
✓ Branch 0 taken 34672 times.
✓ Branch 1 taken 8668 times.
43340 for(int32_t i=0; i<4; i++)
17075 {
17076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34672 times.
34672 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17077 return qe_invalid;
17078 34672 }
17079
2/2
✓ Branch 0 taken 34672 times.
✓ Branch 1 taken 8668 times.
43340 for(int32_t i=0; i<4; i++)
17080 {
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34672 times.
34672 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17082 return qe_invalid;
17083 34672 }
17084
2/2
✓ Branch 0 taken 34672 times.
✓ Branch 1 taken 8668 times.
43340 for(int32_t i=0; i<4; i++)
17085 {
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34672 times.
34672 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17087 return qe_invalid;
17088 34672 }
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8668 times.
8668 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17090 return qe_invalid;
17091
1/2
✓ Branch 0 taken 8668 times.
✗ Branch 1 not taken.
8668 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17092 return qe_invalid;
17093 8668 }
17094
2/2
✓ Branch 0 taken 99733 times.
✓ Branch 1 taken 6691 times.
106424 if(scr_has_flags & SCRHAS_WARPRET)
17095 {
17096
2/2
✓ Branch 0 taken 26764 times.
✓ Branch 1 taken 6691 times.
33455 for(int32_t i=0; i<4; i++)
17097 {
17098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26764 times.
26764 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17099 return qe_invalid;
17100 26764 }
17101
2/2
✓ Branch 0 taken 26764 times.
✓ Branch 1 taken 6691 times.
33455 for(int32_t i=0; i<4; i++)
17102 {
17103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26764 times.
26764 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17104 return qe_invalid;
17105 26764 }
17106
1/2
✓ Branch 0 taken 6691 times.
✗ Branch 1 not taken.
6691 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 6691 times.
✗ Branch 1 not taken.
6691 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17109 return qe_invalid;
17110 6691 }
17111
2/2
✓ Branch 0 taken 92896 times.
✓ Branch 1 taken 13528 times.
106424 if(scr_has_flags & SCRHAS_LAYERS)
17112 {
17113
2/2
✓ Branch 0 taken 81168 times.
✓ Branch 1 taken 13528 times.
94696 for(int32_t k=0; k<6; k++)
17114 {
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81168 times.
81168 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17116 return qe_invalid;
17117 81168 }
17118
2/2
✓ Branch 0 taken 81168 times.
✓ Branch 1 taken 13528 times.
94696 for(int32_t k=0; k<6; k++)
17119 {
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81168 times.
81168 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17121 return qe_invalid;
17122 81168 }
17123
2/2
✓ Branch 0 taken 81168 times.
✓ Branch 1 taken 13528 times.
94696 for(int32_t k=0; k<6; k++)
17124 {
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81168 times.
81168 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17126 return qe_invalid;
17127 81168 }
17128
1/2
✓ Branch 0 taken 13528 times.
✗ Branch 1 not taken.
13528 if(!p_getc(&(temp_mapscr->hidelayers),f))
17129 return qe_invalid;
17130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13528 times.
13528 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17131 return qe_invalid;
17132 13528 }
17133
2/2
✓ Branch 0 taken 106320 times.
✓ Branch 1 taken 104 times.
106424 if(scr_has_flags & SCRHAS_MAZE)
17134 {
17135
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17136 {
17137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17138 return qe_invalid;
17139 416 }
17140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17141 return qe_invalid;
17142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17143 {
17144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17145 return qe_invalid;
17146 104 }
17147 104 }
17148
2/2
✓ Branch 0 taken 77498 times.
✓ Branch 1 taken 28926 times.
106424 if(scr_has_flags & SCRHAS_D_S_U)
17149 {
17150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77498 times.
77498 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17151 return qe_invalid;
17152
2/2
✓ Branch 0 taken 309992 times.
✓ Branch 1 taken 77498 times.
387490 for(int32_t k=0; k<4; k++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 309992 times.
309992 if(!p_getc(&(temp_mapscr->door[k]),f))
17155 return qe_invalid;
17156
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 309632 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
309992 if(version < 29 && temp_mapscr->door[k] == dNONE)
17157 temp_mapscr->door[k] = dWALL;
17158 309992 }
17159
17160
1/2
✓ Branch 0 taken 77498 times.
✗ Branch 1 not taken.
77498 if(!p_getc(&(temp_mapscr->stairx),f))
17161 return qe_invalid;
17162
17163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77498 times.
77498 if(!p_getc(&(temp_mapscr->stairy),f))
17164 return qe_invalid;
17165
1/2
✓ Branch 0 taken 77498 times.
✗ Branch 1 not taken.
77498 if(!p_igetw(&(temp_mapscr->undercombo),f))
17166 return qe_invalid;
17167
1/2
✓ Branch 0 taken 77498 times.
✗ Branch 1 not taken.
77498 if(!p_getc(&(temp_mapscr->undercset),f))
17168 return qe_invalid;
17169 77498 }
17170
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 18438 times.
28926 else if(version < 29)
17171 {
17172
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17173 41952 temp_mapscr->door[k] = dWALL;
17174 10488 }
17175
2/2
✓ Branch 0 taken 99921 times.
✓ Branch 1 taken 6503 times.
106424 if(scr_has_flags & SCRHAS_FLAGS)
17176 {
17177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6503 times.
6503 if(!p_getc(&(temp_mapscr->flags),f))
17178 return qe_invalid;
17179
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags2),f))
17180 return qe_invalid;
17181
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags3),f))
17182 return qe_invalid;
17183
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags4),f))
17184 return qe_invalid;
17185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6503 times.
6503 if(!p_getc(&(temp_mapscr->flags5),f))
17186 return qe_invalid;
17187
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags6),f))
17188 return qe_invalid;
17189
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags7),f))
17190 return qe_invalid;
17191
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags8),f))
17192 return qe_invalid;
17193
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags9),f))
17194 return qe_invalid;
17195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6503 times.
6503 if(!p_getc(&(temp_mapscr->flags10),f))
17196 return qe_invalid;
17197
1/2
✓ Branch 0 taken 6503 times.
✗ Branch 1 not taken.
6503 if(!p_getc(&(temp_mapscr->flags11),f))
17198 return qe_invalid;
17199 6503 }
17200
2/2
✓ Branch 0 taken 101133 times.
✓ Branch 1 taken 5291 times.
106424 if(scr_has_flags & SCRHAS_ENEMY)
17201 {
17202
2/2
✓ Branch 0 taken 52910 times.
✓ Branch 1 taken 5291 times.
58201 for(int32_t k=0; k<10; k++)
17203 {
17204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52910 times.
52910 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17205 return qe_invalid;
17206
1/2
✓ Branch 0 taken 52910 times.
✗ Branch 1 not taken.
52910 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17207 temp_mapscr->enemy[k] = 0;
17208 52910 }
17209
1/2
✓ Branch 0 taken 5291 times.
✗ Branch 1 not taken.
5291 if(!p_getc(&(temp_mapscr->pattern),f))
17210 return qe_invalid;
17211 5291 }
17212
2/2
✓ Branch 0 taken 37024 times.
✓ Branch 1 taken 69400 times.
106424 if(scr_has_flags & SCRHAS_CARRY)
17213 {
17214
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 36666 times.
37024 if(version < 34)
17215 {
17216 word tmpw;
17217
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 if(!p_igetw(&tmpw,f))
17218 return qe_invalid;
17219 358 temp_mapscr->noreset = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED;
17220
1/2
✓ Branch 0 taken 358 times.
✗ Branch 1 not taken.
358 if(!p_igetw(&tmpw,f))
17221 return qe_invalid;
17222 716 temp_mapscr->nocarry = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED |
17223 358 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17224 358 }
17225 else
17226 {
17227
1/2
✓ Branch 0 taken 36666 times.
✗ Branch 1 not taken.
36666 if(!p_igetl(&(temp_mapscr->noreset),f))
17228 return qe_invalid;
17229
1/2
✓ Branch 0 taken 36666 times.
✗ Branch 1 not taken.
36666 if(!p_igetl(&(temp_mapscr->nocarry),f))
17230 return qe_invalid;
17231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36666 times.
36666 if(!p_igetl(&(temp_mapscr->exstate_reset),f))
17232 return qe_invalid;
17233
1/2
✓ Branch 0 taken 36666 times.
✗ Branch 1 not taken.
36666 if(!p_igetl(&(temp_mapscr->exstate_carry),f))
17234 return qe_invalid;
17235 }
17236
1/2
✓ Branch 0 taken 37024 times.
✗ Branch 1 not taken.
37024 if(!p_getc(&(temp_mapscr->nextmap),f))
17237 return qe_invalid;
17238
1/2
✓ Branch 0 taken 37024 times.
✗ Branch 1 not taken.
37024 if(!p_getc(&(temp_mapscr->nextscr),f))
17239 return qe_invalid;
17240 37024 }
17241 else
17242 {
17243
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 69386 times.
69400 if(version < 34)
17244 {
17245 69386 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
17246 69386 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
17247 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17248 69386 }
17249 }
17250
2/2
✓ Branch 0 taken 105827 times.
✓ Branch 1 taken 597 times.
106424 if(scr_has_flags & SCRHAS_SCRIPT)
17251 {
17252
1/2
✓ Branch 0 taken 597 times.
✗ Branch 1 not taken.
597 if(!p_igetw(&(temp_mapscr->script),f))
17253 return qe_invalid;
17254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 597 times.
597 if(!p_getc(&(temp_mapscr->preloadscript),f))
17255 return qe_invalid;
17256
2/2
✓ Branch 0 taken 4776 times.
✓ Branch 1 taken 597 times.
5373 for ( int32_t q = 0; q < 8; q++ )
17257 {
17258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4776 times.
4776 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17259 return qe_invalid;
17260 4776 }
17261 597 }
17262
2/2
✓ Branch 0 taken 74932 times.
✓ Branch 1 taken 31492 times.
106424 if(scr_has_flags & SCRHAS_SECRETS)
17263 {
17264
2/2
✓ Branch 0 taken 4030976 times.
✓ Branch 1 taken 31492 times.
4062468 for(int32_t k=0; k<128; k++)
17265 {
17266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4030976 times.
4030976 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17267 return qe_invalid;
17268 4030976 }
17269
2/2
✓ Branch 0 taken 4030976 times.
✓ Branch 1 taken 31492 times.
4062468 for(int32_t k=0; k<128; k++)
17270 {
17271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4030976 times.
4030976 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17272 return qe_invalid;
17273 4030976 }
17274
2/2
✓ Branch 0 taken 4030976 times.
✓ Branch 1 taken 31492 times.
4062468 for(int32_t k=0; k<128; k++)
17275 {
17276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4030976 times.
4030976 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17277 return qe_invalid;
17278 4030976 }
17279 31492 }
17280
2/2
✓ Branch 0 taken 40663 times.
✓ Branch 1 taken 65761 times.
106424 if(scr_has_flags & SCRHAS_COMBOFLAG)
17281 {
17282
2/2
✓ Branch 0 taken 11573936 times.
✓ Branch 1 taken 65761 times.
11639697 for(int32_t k=0; k<176; ++k)
17283 {
17284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11573936 times.
11573936 if(!p_igetw(&(temp_mapscr->data[k]),f))
17285 return qe_invalid;
17286 11573936 }
17287
2/2
✓ Branch 0 taken 11573936 times.
✓ Branch 1 taken 65761 times.
11639697 for(int32_t k=0; k<176; ++k)
17288 {
17289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11573936 times.
11573936 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17290 return qe_invalid;
17291 11573936 }
17292
2/2
✓ Branch 0 taken 11573936 times.
✓ Branch 1 taken 65761 times.
11639697 for(int32_t k=0; k<176; ++k)
17293 {
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11573936 times.
11573936 if(!p_getc(&(temp_mapscr->cset[k]),f))
17295 return qe_invalid;
17296 11573936 }
17297 65761 }
17298
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(scr_has_flags & SCRHAS_MISC)
17299 {
17300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106424 times.
106424 if(!p_igetw(&(temp_mapscr->color),f))
17301 return qe_invalid;
17302
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->csensitive),f))
17303 return qe_invalid;
17304
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->oceansfx),f))
17305 return qe_invalid;
17306
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->bosssfx),f))
17307 return qe_invalid;
17308
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->secretsfx),f))
17309 return qe_invalid;
17310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106424 times.
106424 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17311 return qe_invalid;
17312
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17313 return qe_invalid;
17314
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17315 return qe_invalid;
17316
1/2
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
106424 if(!p_getc(&(temp_mapscr->lens_layer),f))
17317 return qe_invalid;
17318
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 95846 times.
106424 if(version > 27)
17319 {
17320
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_getc(&(temp_mapscr->lens_show),f))
17321 return qe_invalid;
17322
1/2
✓ Branch 0 taken 95846 times.
✗ Branch 1 not taken.
95846 if(!p_getc(&(temp_mapscr->lens_hide),f))
17323 return qe_invalid;
17324 95846 }
17325 106424 }
17326 else
17327 {
17328 temp_mapscr->screen_midi = -1;
17329 temp_mapscr->csensitive = 1;
17330 }
17331 //FFC
17332 106424 bool old_ff = version < 25;
17333 106424 dword bits = 0;
17334 106424 word numffc = 32;
17335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106424 times.
106424 if(old_ff)
17336 {
17337 if(!p_igetl(&bits,f))
17338 return qe_invalid;
17339 }
17340 else
17341 {
17342
2/4
✓ Branch 0 taken 106424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 106424 times.
106424 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17343 return qe_invalid;
17344 }
17345
17346 106424 temp_mapscr->ffcCountMarkDirty();
17347 106424 temp_mapscr->ffcs.clear();
17348 106424 temp_mapscr->resizeFFC(numffc);
17349
17350 byte tempbyte;
17351 word tempw;
17352
4/6
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 106260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 164 times.
✓ Branch 4 taken 164 times.
✗ Branch 5 not taken.
106424 static ffcdata nil_ffc;
17353
2/2
✓ Branch 0 taken 1982056 times.
✓ Branch 1 taken 106424 times.
2088480 for(word m = 0; m < numffc; ++m)
17354 {
17355
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1982056 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1982056 if(old_ff && !(bits & (1<<m))) continue;
17356
17357
1/2
✓ Branch 0 taken 1982056 times.
✗ Branch 1 not taken.
1982056 ffcdata& tempffc = (m < MAXFFCS)
17358 1982056 ? temp_mapscr->ffcs[m]
17359 : nil_ffc; //sanity
17360
17361
1/2
✓ Branch 0 taken 1982056 times.
✗ Branch 1 not taken.
1982056 if(!p_igetw(&tempw,f))
17362 return qe_invalid;
17363
3/4
✓ Branch 0 taken 1982056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14633 times.
✓ Branch 3 taken 1967423 times.
1982056 if(!old_ff && !tempw) //empty ffc, nothing more to load
17364 1967423 continue;
17365 14633 tempffc.data = tempw;
17366
17367
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_getc(&(tempffc.cset),f))
17368 return qe_invalid;
17369
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetw(&(tempffc.delay),f))
17370 return qe_invalid;
17371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetzf(&(tempffc.x),f))
17372 return qe_invalid;
17373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetzf(&(tempffc.y),f))
17374 return qe_invalid;
17375
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetzf(&(tempffc.vx),f))
17376 return qe_invalid;
17377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetzf(&(tempffc.vy),f))
17378 return qe_invalid;
17379
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetzf(&(tempffc.ax),f))
17380 return qe_invalid;
17381
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetzf(&(tempffc.ay),f))
17382 return qe_invalid;
17383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_getc(&(tempffc.link),f))
17384 return qe_invalid;
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(version < 24)
17386 {
17387 if(!p_getc(&tempbyte,f))
17388 return qe_invalid;
17389 tempffc.hit_width = (tempbyte&0x3F)+1;
17390 tempffc.txsz = (tempbyte>>6)+1;
17391 if(!p_getc(&tempbyte,f))
17392 return qe_invalid;
17393 tempffc.hit_height = (tempbyte&0x3F)+1;
17394 tempffc.tysz = (tempbyte>>6)+1;
17395 }
17396 else
17397 {
17398
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetl(&(tempffc.hit_width),f))
17399 return qe_invalid;
17400
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetl(&(tempffc.hit_height),f))
17401 return qe_invalid;
17402
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_getc(&(tempffc.txsz),f))
17403 return qe_invalid;
17404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_getc(&(tempffc.tysz),f))
17405 return qe_invalid;
17406 }
17407
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(!p_igetl(&(tempffc.flags),f))
17408 return qe_invalid;
17409 14633 tempffc.updateSolid();
17410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14633 times.
14633 if(!p_igetw(&(tempffc.script),f))
17411 return qe_invalid;
17412
2/2
✓ Branch 0 taken 117064 times.
✓ Branch 1 taken 14633 times.
131697 for(auto q = 0; q < 8; ++q)
17413 {
17414
1/2
✓ Branch 0 taken 117064 times.
✗ Branch 1 not taken.
117064 if(!p_igetl(&(tempffc.initd[q]),f))
17415 return qe_invalid;
17416 117064 }
17417
2/2
✓ Branch 0 taken 8011 times.
✓ Branch 1 taken 6622 times.
14633 if(version < 33)
17418 {
17419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17420 return qe_invalid;
17421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(!p_getc(&(tempbyte),f))
17422 return qe_invalid;
17423 8011 }
17424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6622 times.
6622 else if(!p_getc(&(tempffc.layer),f))
17425 return qe_invalid;
17426
17427
1/2
✓ Branch 0 taken 14633 times.
✗ Branch 1 not taken.
14633 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17428 {
17429 tempffc.script = 0;
17430 for(int q = 0; q < 8; ++q)
17431 tempffc.initd[q] = 0;
17432 }
17433 14633 }
17434 //END FFC
17435
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 67927 times.
106424 if(version > 29)
17436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67927 times.
67927 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17437 return qe_invalid;
17438
17439
4/4
✓ Branch 0 taken 36680 times.
✓ Branch 1 taken 69744 times.
✓ Branch 2 taken 36632 times.
✓ Branch 3 taken 48 times.
106424 if (version >= 35 && (temp_mapscr->flags10 & fSCREEN_GRAVITY))
17440 {
17441
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if (!p_igetzf(&temp_mapscr->screen_gravity, f))
17442 return qe_invalid;
17443
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if (!p_igetzf(&temp_mapscr->screen_terminal_v, f))
17444 return qe_invalid;
17445 48 }
17446 }
17447
17448 1285280 temp_mapscr->shrinkToFitFFCs();
17449
17450 1285280 return 0;
17451 1385576 }
17452
17453 481 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17454 {
17455
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17456 481 int32_t screen=0;
17457
17458 481 word version=0;
17459 dword dummy;
17460 int32_t screens_to_read;
17461
17462 481 mapscr temp_mapscr{};
17463 word temp_map_count;
17464 dword section_size;
17465
17466
5/6
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
481 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17467 {
17468 18 screens_to_read=MAPSCRS192b136;
17469 18 }
17470 else
17471 {
17472 463 screens_to_read=MAPSCRS;
17473 }
17474
17475
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 if(Header->zelda_version > 0x192)
17476 {
17477 //section version info
17478
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&version,f))
17479 {
17480 return qe_invalid;
17481 }
17482
17483
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (version > V_MAPS)
17484 return qe_version;
17485
17486 457 FFCore.quest_format[vMaps] = version;
17487
17488
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&dummy,f))
17489 {
17490 return qe_invalid;
17491 }
17492
17493 //section size
17494
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&section_size,f))
17495 {
17496 return qe_invalid;
17497 }
17498
17499 //finally... section data
17500
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&temp_map_count,f))
17501 {
17502 return 5;
17503 }
17504 457 }
17505 else
17506 {
17507 24 temp_map_count=map_count;
17508 }
17509
17510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
481 if (temp_map_count > MAXMAPS)
17511 {
17512 return qe_invalid;
17513 }
17514
17515
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1 times.
481 if (!should_skip)
17516 {
17517 480 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17518 480 TheMaps.clear();
17519
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 TheMaps.resize(_mapsSize);
17520 480 old_combo_pages.clear();
17521
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 old_combo_pages.resize(_mapsSize);
17522 480 map_infos.clear();
17523
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 map_infos.resize(temp_map_count);
17524
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 153 times.
480 if(version >= 31)
17525 153 Regions = {};
17526 480 }
17527
17528
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 10326 times.
✓ Branch 2 taken 10326 times.
✓ Branch 3 taken 481 times.
10807 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17529 {
17530 10326 byte valid=1;
17531
2/2
✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 8673 times.
10326 if(version > 22)
17532 {
17533
2/4
✓ Branch 0 taken 1653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1653 times.
✗ Branch 3 not taken.
1653 if(!p_getc(&valid,f))
17534 return qe_invalid;
17535 1653 }
17536
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 10193 times.
10326 if(valid)
17537 {
17538
2/2
✓ Branch 0 taken 8803 times.
✓ Branch 1 taken 1390 times.
10193 if (version > 25)
17539 {
17540 1390 auto& mapinf = map_infos[i];
17541
2/2
✓ Branch 0 taken 8340 times.
✓ Branch 1 taken 1390 times.
9730 for(int q = 0; q < 6; ++q)
17542 {
17543
2/4
✓ Branch 0 taken 8340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8340 times.
✗ Branch 3 not taken.
8340 if(!p_igetw(&mapinf.autolayers[q],f))
17544 return qe_invalid;
17545 8340 }
17546
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 770 times.
1390 if (version >= 36)
17547
2/4
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
620 if(!p_igetw(&mapinf.autopalette,f))
17548 return qe_invalid;
17549 1390 }
17550
17551
2/2
✓ Branch 0 taken 9245 times.
✓ Branch 1 taken 948 times.
10193 if (version >= 31)
17552 {
17553 static regions_data tmp_rd;
17554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 948 times.
948 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17555
2/2
✓ Branch 0 taken 7584 times.
✓ Branch 1 taken 948 times.
8532 for(int32_t j=0; j<8; j++)
17556 {
17557
2/2
✓ Branch 0 taken 60672 times.
✓ Branch 1 taken 7584 times.
68256 for(int32_t k=0; k<8; k++)
17558 {
17559
2/4
✓ Branch 0 taken 60672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60672 times.
✗ Branch 3 not taken.
60672 if(!p_getc(&rd.region_ids[j][k],f))
17560 {
17561 return qe_invalid;
17562 }
17563 60672 }
17564 7584 }
17565 948 }
17566 10193 }
17567
2/2
✓ Branch 0 taken 1403664 times.
✓ Branch 1 taken 10326 times.
1413990 for(int32_t j=0; j<screens_to_read; j++)
17568 {
17569 1403664 screen=i*MAPSCRS+j;
17570
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1403392 times.
1403664 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17571 1403664 scr->map = i;
17572 1403664 scr->screen = j;
17573
2/2
✓ Branch 0 taken 1385576 times.
✓ Branch 1 taken 18088 times.
1403664 if(valid)
17574
1/2
✓ Branch 0 taken 1385576 times.
✗ Branch 1 not taken.
1385576 readmapscreen(f, Header, scr, version, screen);
17575
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 else if (!should_skip)
17576
1/2
✓ Branch 0 taken 18088 times.
✗ Branch 1 not taken.
18088 clear_screen(scr);
17577 1403664 }
17578
17579
2/2
✓ Branch 0 taken 10324 times.
✓ Branch 1 taken 2 times.
10326 if (should_skip)
17580 2 continue;
17581
17582
5/6
✓ Branch 0 taken 10156 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10138 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10324 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17583 {
17584 168 int32_t index = (i*MAPSCRS+132);
17585
17586
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17587
17588 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17589 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17590 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17591
17592
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17593 {
17594 504 screen=i*MAPSCRS+j;
17595
17596
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17597 504 TheMaps[screen].valid = mVERSION;
17598 504 TheMaps[screen].screen_midi = -1;
17599 504 TheMaps[screen].csensitive = 1;
17600 504 }
17601 168 }
17602
17603
5/6
✓ Branch 0 taken 10156 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 10138 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
10324 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17604 {
17605
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17606 {
17607 22848 screen=i*MAPSCRS+j;
17608
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17609
17610
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17611 {
17612
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17613
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17614
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17615 2924544 }
17616 22848 }
17617 168 }
17618 10324 }
17619 481 map_count = temp_map_count;
17620 481 return 0;
17621 481 }
17622
17623
17624 9042676 void update_combo(newcombo& cmb, word section_version)
17625 {
17626
2/2
✓ Branch 0 taken 1360657 times.
✓ Branch 1 taken 7682019 times.
9042676 if(section_version < 40)
17627 {
17628
3/3
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 45418 times.
✓ Branch 2 taken 7631457 times.
7682019 switch(cmb.type)
17629 {
17630 case cWATER: case cSHALLOWWATER:
17631 45418 cmb.attribytes[6] = iwRipples;
17632 45418 break;
17633 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17634 5144 cmb.attribytes[6] = iwTallGrass;
17635 5144 break;
17636 }
17637 7682019 }
17638
2/2
✓ Branch 0 taken 1013226 times.
✓ Branch 1 taken 8029450 times.
9042676 if(section_version < 49)
17639 {
17640
4/4
✓ Branch 0 taken 7994679 times.
✓ Branch 1 taken 34771 times.
✓ Branch 2 taken 15455 times.
✓ Branch 3 taken 7979224 times.
8029450 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17641 50226 cmb.sfx_landing = WAV_ZN1SPLASH;
17642 8029450 }
17643 9042676 }
17644 288 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17645 {
17646
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 24 times.
288 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17647 byte tempbyte;
17648
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17649 {
17650 287 reset_all_combo_animations();
17651 287 init_combo_classes();
17652 287 }
17653
17654 // combos
17655 288 word combos_used=0;
17656 int32_t dummy;
17657 byte padding;
17658 288 newcombo temp_combo;
17659
17660
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17661
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17662
1/2
✓ Branch 0 taken 18735360 times.
✗ Branch 1 not taken.
18735647 combobuf[q].clear();
17663
17664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(version < 0x174)
17665 {
17666 combos_used=1024;
17667 }
17668
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 18 times.
288 else if(version < 0x191)
17669 {
17670 18 combos_used=2048;
17671 18 }
17672 else
17673 {
17674
2/4
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
270 if(!p_igetw(&combos_used,f))
17675 {
17676 return qe_invalid;
17677 }
17678 }
17679
17680 //finally... section data
17681
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 288 times.
7547291 for(int32_t i=0; i<combos_used; i++)
17682 {
17683
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_combo.clear();
17684
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17685 7547003 int32_t temp_trigflags[6] = {0};
17686
17687
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if ( section_version >= 11 )
17688 {
17689
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17690 {
17691 return qe_invalid;
17692 }
17693 202968 }
17694 else
17695 {
17696
2/4
✓ Branch 0 taken 7344035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7344035 times.
✗ Branch 3 not taken.
7344035 if(!p_igetw(&temp_combo.tile,f))
17697 {
17698 return qe_invalid;
17699 }
17700 }
17701 7547003 temp_combo.o_tile = temp_combo.tile;
17702
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.flip,f))
17703 {
17704 return qe_invalid;
17705 }
17706
17707
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.walk,f))
17708 {
17709 return qe_invalid;
17710 }
17711
17712
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.type,f))
17713 {
17714 return qe_invalid;
17715 }
17716
17717
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.csets,f))
17718 {
17719 return qe_invalid;
17720 }
17721
17722
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7477229 times.
7547003 if(version < 0x193)
17723 {
17724
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17725 return qe_invalid;
17726
17727
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17728 return qe_invalid;
17729
17730
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17731 {
17732
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17733 {
17734 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17735 {
17736 if(!p_getc(&padding,f))
17737 return qe_invalid;
17738 }
17739 }
17740 36864 }
17741 69774 }
17742
2/2
✓ Branch 0 taken 7510139 times.
✓ Branch 1 taken 36864 times.
7547003 if(version >= 0x192)
17743 {
17744
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.frames,f))
17745 return qe_invalid;
17746
17747
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.speed,f))
17748 return qe_invalid;
17749
17750
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_igetw(&temp_combo.nextcombo,f))
17751 return qe_invalid;
17752
17753
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.nextcset,f))
17754 return qe_invalid;
17755
17756 //Base flag
17757
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=3)
17758
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.flag,f))
17759 return qe_invalid;
17760
17761
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=4)
17762 {
17763
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanim,f))
17764 return qe_invalid;
17765
17766
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_igetw(&temp_combo.nexttimer,f))
17767 return qe_invalid;
17768 4621731 }
17769
17770
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=5)
17771
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanimy,f))
17772 return qe_invalid;
17773
17774
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=6)
17775 {
17776
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.animflags,f))
17777 return qe_invalid;
17778
17779
1/2
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
4621731 if(section_version == 6)
17780 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17781 4621731 }
17782
17783
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=8) //combo Attributes[4] and userflags.
17784 {
17785
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17786
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17787 return qe_invalid;
17788
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17789 return qe_invalid;
17790
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17791
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17792 return qe_invalid;
17793 202968 }
17794
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=10) //combo trigger flags
17795 {
17796
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17797
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigflags[q],f))
17798 return qe_invalid;
17799 202968 }
17800
1/2
✓ Branch 0 taken 7307171 times.
✗ Branch 1 not taken.
7307171 else if(section_version==9) //combo trigger flags, V9 only had two indices
17801 {
17802 for ( int32_t q = 0; q < 2; q++ )
17803 if(!p_igetl(&temp_trigflags[q],f))
17804 return qe_invalid;
17805 }
17806
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 9)
17807
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17808 return qe_invalid;
17809
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 22)
17810
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17811 return qe_invalid;
17812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 24)
17813 {
17814 if(!p_getc(&temp_trigger.triggeritem,f))
17815 return qe_invalid;
17816 if(!p_getc(&tempbyte, f))
17817 return qe_invalid;
17818 temp_trigger.trigtimer = tempbyte;
17819 }
17820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 25)
17821 if(!p_getc(&temp_trigger.trigsfx,f))
17822 return qe_invalid;
17823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 27)
17824 if(!p_igetl(&temp_trigger.trigchange,f))
17825 return qe_invalid;
17826
17827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 29)
17828 {
17829 if(!p_igetw(&temp_trigger.trigprox,f))
17830 return qe_invalid;
17831 if(!p_getc(&tempbyte,f))
17832 return qe_invalid;
17833 temp_trigger.trigctr = tempbyte;
17834 if(!p_igetl(&temp_trigger.trigctramnt,f))
17835 return qe_invalid;
17836 }
17837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 30)
17838 if(!p_getc(&temp_trigger.triglbeam,f))
17839 return qe_invalid;
17840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 31)
17841 {
17842 if(!p_getc(&temp_trigger.trigcschange,f))
17843 return qe_invalid;
17844 if(!p_igetw(&temp_trigger.spawnitem,f))
17845 return qe_invalid;
17846 if(!p_igetw(&temp_trigger.spawnenemy,f))
17847 return qe_invalid;
17848 if(!p_getc(&temp_trigger.exstate,f))
17849 return qe_invalid;
17850 if(!p_igetl(&temp_trigger.spawnip,f))
17851 return qe_invalid;
17852 if(!p_getc(&temp_trigger.trigcopycat,f))
17853 return qe_invalid;
17854 }
17855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 32)
17856 if(!p_getc(&temp_trigger.trigcooldown,f))
17857 return qe_invalid;
17858
17859
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=12) //combo label
17860 {
17861 char label[12];
17862 202968 label[11] = '\0';
17863
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17864
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17865 return qe_invalid;
17866
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17867 202968 }
17868
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=13) //attribytes[4]
17869
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17870
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17871 202968 return qe_invalid;
17872 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17873 * This fixes a poor implementation of a ->next flag bug thing.
17874 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17875 * there was a version bump a few weeks before a change that broke stuff.
17876 */
17877
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if (section_version >= 13 && section_version < 21)
17878 {
17879 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17880 }
17881 //combo scripts
17882
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=14)
17883 {
17884
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17885 return qe_invalid;
17886
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17887
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17888 return qe_invalid;
17889 202968 }
17890
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=15)
17891 {
17892
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17893
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17894
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17895
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17896 202968 }
17897
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=17) //attribytes[4]
17898 {
17899
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17900
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17901 return qe_invalid;
17902
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17903
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17904 return qe_invalid;
17905 202968 }
17906
17907
2/2
✓ Branch 0 taken 7477229 times.
✓ Branch 1 taken 32910 times.
7510139 if(version < 0x193)
17908
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17909
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17910 32910 return qe_invalid;
17911 7510139 }
17912
17913 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17914
3/6
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4621731 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7547003 if((version < 0x211)||((version == 0x211)&&(build<7)))
17915 {
17916
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17917 {
17918
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17919 {
17920 case 130:
17921 temp_combo.tile = 132;
17922 break;
17923
17924 case 131:
17925 temp_combo.tile = 133;
17926 break;
17927
17928 case 132:
17929 temp_combo.tile = 130;
17930 break;
17931
17932 case 133:
17933 temp_combo.tile = 131;
17934 break;
17935 }
17936 39936 }
17937 2925272 }
17938
17939
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 15)
17940 7344035 temp_combo.o_tile = temp_combo.tile;
17941
17942
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version<18) //upper bits for .walk
17943 7344035 temp_combo.walk |= 0xF0;
17944
17945
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 19)
17946
2/2
✓ Branch 0 taken 29376140 times.
✓ Branch 1 taken 7344035 times.
36720175 for(int32_t q = 0; q < 4; ++q)
17947 36720175 temp_combo.attributes[q] *= 10000L;
17948
17949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 23)
17950 {
17951
2/2
✓ Branch 0 taken 15235 times.
✓ Branch 1 taken 7531768 times.
7547003 switch(temp_combo.type) //TRIGFLAG_CMBTYPEFX now required for combotype-specific effects
17952 {
17953 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17954 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17955 case cTRIGGERGENERIC: case cCSWITCH:
17956 15235 temp_trigflags[TRIGFLAG_CMBTYPEFX/32] |= 1<<(TRIGFLAG_CMBTYPEFX%32);
17957 15235 }
17958 7547003 }
17959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 25)
17960 {
17961
2/2
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 7519607 times.
7547003 switch(temp_combo.type)
17962 {
17963 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27396 times.
27396 if(!(temp_combo.usrflags & cflag3))
17965 27396 temp_combo.attribytes[3] = WAV_DOOR;
17966 27396 temp_combo.usrflags &= ~cflag3;
17967 27396 break;
17968 }
17969 7547003 }
17970
17971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 26)
17972
2/2
✓ Branch 0 taken 7545882 times.
✓ Branch 1 taken 1121 times.
7548124 if(temp_combo.type == cARMOS)
17973
1/2
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
1121 if(temp_combo.usrflags & cflag1)
17974 temp_combo.usrflags |= cflag3;
17975
17976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 27)
17977 {
17978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(temp_trigflags[0] & 0x00040000) //'next'
17979 temp_trigger.trigchange = 1;
17980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 else if(temp_trigflags[0] & 0x00080000) //'prev'
17981 temp_trigger.trigchange = -1;
17982 7547003 else temp_trigger.trigchange = 0;
17983 7547003 temp_trigflags[0] &= ~(0x00040000|0x00080000);
17984 7547003 }
17985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 28)
17986 {
17987
2/2
✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 7531491 times.
7547003 switch(temp_combo.type)
17988 {
17989 case cLOCKBLOCK: case cLOCKEDCHEST:
17990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15512 times.
15512 if(temp_combo.usrflags & cflag7)
17991 temp_combo.usrflags |= cflag8;
17992 15512 else temp_combo.usrflags &= ~cflag8;
17993 15512 temp_combo.usrflags &= ~cflag7;
17994 15512 break;
17995 }
17996
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 7546245 times.
7547003 switch(temp_combo.type)
17997 {
17998 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17999 758 temp_combo.attrishorts[2] = -1;
18000 758 temp_combo.usrflags |= cflag7;
18001 758 break;
18002 }
18003 7547003 }
18004
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 20)
18005 {
18006 7344035 temp_combo.genflags = 0;
18007
2/2
✓ Branch 0 taken 143987 times.
✓ Branch 1 taken 7200048 times.
7344035 switch(temp_combo.type)
18008 {
18009 case cPUSH_WAIT: case cPUSH_HEAVY:
18010 case cPUSH_HW: case cL_STATUE:
18011 case cR_STATUE: case cPUSH_HEAVY2:
18012 case cPUSH_HW2: case cPOUND:
18013 case cC_STATUE: case cMIRROR:
18014 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18015 case cMAGICPRISM: case cMAGICPRISM4:
18016 case cMAGICSPONGE: case cEYEBALL_A:
18017 case cEYEBALL_B: case cEYEBALL_4:
18018 case cBUSH: case cFLOWERS:
18019 case cLOCKBLOCK: case cLOCKBLOCK2:
18020 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18021 case cCHEST: case cCHEST2:
18022 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18023 case cBOSSCHEST: case cBOSSCHEST2:
18024 case cBUSHNEXT: case cBUSHTOUCHY:
18025 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18026 case cSIGNPOST: case cCSWITCHBLOCK:
18027 case cTORCH: case cTRIGGERGENERIC:
18028
1/2
✓ Branch 0 taken 143987 times.
✗ Branch 1 not taken.
143987 if(temp_combo.usrflags & cflag16)
18029 {
18030 temp_combo.genflags |= cflag1;
18031 temp_combo.usrflags &= ~cflag16;
18032 }
18033 143987 break;
18034 }
18035 7344035 }
18036
18037
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_trigger.trigger_flags.clear();
18038
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 1449024576 times.
1456571579 for(size_t q = 0; q < 32*6; ++q)
18039 {
18040 1449024576 auto ind = q/32;
18041 1449024576 auto bit = 1<<(q%32);
18042
2/2
✓ Branch 0 taken 1449008300 times.
✓ Branch 1 taken 16276 times.
1449024576 if(temp_trigflags[ind] & bit)
18043
1/2
✓ Branch 0 taken 16276 times.
✗ Branch 1 not taken.
16276 temp_trigger.trigger_flags.set(q, true);
18044 1449024576 }
18045
18046
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15274 times.
✓ Branch 3 taken 7531729 times.
7547003 if(temp_trigger.is_blank())
18047 7531729 temp_combo.triggers.clear();
18048
18049 7547003 update_combo(temp_combo, section_version);
18050
18051
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7532084 times.
✓ Branch 3 taken 14919 times.
7547003 if(i>=start_combo && !should_skip)
18052 {
18053
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18054 {
18055 temp_combo.script = 0;
18056 for(int q = 0; q < 8; ++q)
18057 temp_combo.initd[q] = 0;
18058 }
18059
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 combobuf[i] = temp_combo;
18060 7532084 }
18061 7547003 }
18062
18063
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 1 times.
288 if (should_skip)
18064 1 return 0;
18065
18066
5/6
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
287 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18067 {
18068
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18069 {
18070
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18071 {
18072 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18073 215 }
18074 1501440 }
18075 23 }
18076
18077 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18078
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
287 if(version == 0x210 && get_app_id() != App::zquest)
18079 {
18080
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18081
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
18082 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18083 59 }
18084
18085
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<7)
18086 {
18087
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18088 {
18089
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
18090 {
18091 case cSLASH:
18092 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18093 853 break;
18094
18095 case cSLASHITEM:
18096 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18097 791 break;
18098
18099 case cBUSH:
18100 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18101 603 break;
18102
18103 case cFLOWERS:
18104 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18105 174 break;
18106
18107 case cTALLGRASS:
18108 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18109 531 break;
18110
18111 case cSLASHNEXT:
18112 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18113 break;
18114
18115 case cSLASHNEXTITEM:
18116 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18117 break;
18118
18119 case cBUSHNEXT:
18120 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18121 break;
18122 }
18123 5352960 }
18124 82 }
18125
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
287 if (section_version < 16)
18126 {
18127
2/2
✓ Branch 0 taken 18408960 times.
✓ Branch 1 taken 282 times.
18409242 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18128 {
18129
2/2
✓ Branch 0 taken 18380119 times.
✓ Branch 1 taken 28841 times.
18408960 if (combobuf[tmpcounter].type == cWATER)
18130 {
18131 28841 combobuf[tmpcounter].attributes[0] = 40000L;
18132 28841 }
18133 18408960 }
18134 282 }
18135
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 3 times.
287 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18136 {
18137 3 combobuf[0].walk = 0xF0;
18138 3 combobuf[0].type = 0;
18139 3 combobuf[0].flag = 0;
18140 3 }
18141
18142 //Now for the new combo alias reset
18143
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<2)
18144 {
18145
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18146 {
18147 671744 combo_aliases[j].width = 0;
18148 671744 combo_aliases[j].height = 0;
18149 671744 combo_aliases[j].layermask = 0;
18150
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18151
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18152 671744 }
18153 82 }
18154
18155
18156
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations();
18157
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations2();
18158 287 return 0;
18159 288 }
18160
18161 12915 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18162 {
18163 byte tempbyte;
18164
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 5335 times.
12915 if(s_version >= 52)
18165
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getcstr(&temp_trigger.label,f))
18166 return qe_invalid;
18167
18168
2/2
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 5089 times.
12915 if(s_version < 57)
18169 {
18170 7826 int32_t temp_trigflags[6] = {0};
18171 7826 int numtrigs = s_version < 36 ? 3 : 6;
18172
2/2
✓ Branch 0 taken 46098 times.
✓ Branch 1 taken 7826 times.
53924 for ( int32_t q = 0; q < numtrigs; q++ )
18173
1/2
✓ Branch 0 taken 46098 times.
✗ Branch 1 not taken.
46098 if(!p_igetl(&temp_trigflags[q],f))
18174 return qe_invalid;
18175 7826 temp_trigger.trigger_flags.clear();
18176
2/2
✓ Branch 0 taken 1475136 times.
✓ Branch 1 taken 7826 times.
1482962 for(size_t q = 0; q < 32*numtrigs; ++q)
18177 {
18178 1475136 auto ind = q/32;
18179 1475136 auto bit = 1<<(q%32);
18180
2/2
✓ Branch 0 taken 1461763 times.
✓ Branch 1 taken 13373 times.
1475136 if(temp_trigflags[ind] & bit)
18181 13373 temp_trigger.trigger_flags.set(q, true);
18182 1475136 }
18183 7826 }
18184
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 else if(!p_getbitstr(&temp_trigger.trigger_flags,f))
18185 return qe_invalid;
18186
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.triggerlevel,f))
18187 return qe_invalid;
18188
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.triggerbtn,f))
18189 return qe_invalid;
18190
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.triggeritem,f))
18191 return qe_invalid;
18192
2/2
✓ Branch 0 taken 5335 times.
✓ Branch 1 taken 7580 times.
12915 if(s_version >= 53)
18193 {
18194
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetw(&temp_trigger.trigtimer,f))
18195 return qe_invalid;
18196 5335 }
18197 else
18198 {
18199
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!p_getc(&tempbyte, f))
18200 return qe_invalid;
18201 7580 temp_trigger.trigtimer = tempbyte;
18202 }
18203
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigsfx,f))
18204 return qe_invalid;
18205
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.trigchange,f))
18206 return qe_invalid;
18207
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.trigprox,f))
18208 return qe_invalid;
18209
2/2
✓ Branch 0 taken 5335 times.
✓ Branch 1 taken 7580 times.
12915 if(s_version >= 53)
18210 {
18211
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetw(&temp_trigger.trigctr,f))
18212 return qe_invalid;
18213 5335 }
18214 else
18215 {
18216
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!p_getc(&tempbyte,f))
18217 return qe_invalid;
18218 7580 temp_trigger.trigctr = tempbyte;
18219 }
18220
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.trigctramnt,f))
18221 return qe_invalid;
18222
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.triglbeam,f))
18223 return qe_invalid;
18224
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigcschange,f))
18225 return qe_invalid;
18226
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.spawnitem,f))
18227 return qe_invalid;
18228
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.spawnenemy,f))
18229 return qe_invalid;
18230
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.exstate,f))
18231 return qe_invalid;
18232
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetl(&temp_trigger.spawnip,f))
18233 return qe_invalid;
18234
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigcopycat,f))
18235 return qe_invalid;
18236
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.trigcooldown,f))
18237 return qe_invalid;
18238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12915 times.
12915 if(s_version >= 35)
18239 {
18240
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.prompt_cid,f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_getc(&temp_trigger.prompt_cs,f))
18243 return qe_invalid;
18244
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.prompt_x,f))
18245 return qe_invalid;
18246
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(!p_igetw(&temp_trigger.prompt_y,f))
18247 return qe_invalid;
18248 12915 }
18249
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12629 times.
12915 if(s_version >= 36)
18250 {
18251
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_getc(&temp_trigger.trig_lstate,f))
18252 return qe_invalid;
18253
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_getc(&temp_trigger.trig_gstate,f))
18254 return qe_invalid;
18255
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_igetl(&temp_trigger.trig_statetime,f))
18256 return qe_invalid;
18257 12629 }
18258
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 12629 times.
12915 if(s_version >= 37)
18259 {
18260
1/2
✓ Branch 0 taken 12629 times.
✗ Branch 1 not taken.
12629 if(!p_igetw(&temp_trigger.trig_genscr,f))
18261 return qe_invalid;
18262 12629 }
18263
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 12481 times.
12915 if(s_version >= 38)
18264 {
18265
1/2
✓ Branch 0 taken 12481 times.
✗ Branch 1 not taken.
12481 if(!p_getc(&temp_trigger.trig_group,f))
18266 return qe_invalid;
18267
1/2
✓ Branch 0 taken 12481 times.
✗ Branch 1 not taken.
12481 if(!p_igetw(&temp_trigger.trig_group_val,f))
18268 return qe_invalid;
18269 12481 }
18270
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 12445 times.
12915 if(s_version >= 45)
18271 {
18272
1/2
✓ Branch 0 taken 12445 times.
✗ Branch 1 not taken.
12445 if(!p_getc(&temp_trigger.exdoor_dir,f))
18273 return qe_invalid;
18274
1/2
✓ Branch 0 taken 12445 times.
✗ Branch 1 not taken.
12445 if(!p_getc(&temp_trigger.exdoor_ind,f))
18275 return qe_invalid;
18276 12445 }
18277
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5803 times.
12915 if(s_version >= 46)
18278 {
18279
2/2
✓ Branch 0 taken 4805 times.
✓ Branch 1 taken 998 times.
5803 if (s_version >= 59)
18280 {
18281
1/2
✓ Branch 0 taken 4805 times.
✗ Branch 1 not taken.
4805 if(!p_igetw(&temp_trigger.trig_levelitems,f))
18282 return qe_invalid;
18283 4805 }
18284 else
18285 {
18286
1/2
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
998 if(!p_getc(&tempbyte,f))
18287 return qe_invalid;
18288 998 temp_trigger.trig_levelitems = word(tempbyte);
18289 }
18290
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18291 return qe_invalid;
18292
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(s_version >= 48)
18293 {
18294
2/2
✓ Branch 0 taken 17409 times.
✓ Branch 1 taken 5803 times.
23212 for(int q = 0; q < 3; ++q)
18295
1/2
✓ Branch 0 taken 17409 times.
✗ Branch 1 not taken.
17409 if(!p_igetw(&temp_trigger.trigtint[q],f))
18296 return qe_invalid;
18297 5803 }
18298 else
18299 {
18300 for(int q = 0; q < 3; ++q)
18301 if(!p_getc(&temp_trigger.trigtint[q],f))
18302 return qe_invalid;
18303 for(int q = 0; q < 3; ++q)
18304 {
18305 int v = temp_trigger.trigtint[q];
18306 int va = abs(v);
18307 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18308 }
18309 }
18310
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18311 return qe_invalid;
18312
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18313 return qe_invalid;
18314
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigquaketime,f))
18315 return qe_invalid;
18316
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trigwavytime,f))
18317 return qe_invalid;
18318
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18319 return qe_invalid;
18320
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18321 return qe_invalid;
18322
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18323 return qe_invalid;
18324
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18325 return qe_invalid;
18326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5803 times.
5803 if(!p_getc(&temp_trigger.trig_pushtime,f))
18327 return qe_invalid;
18328 5803 }
18329
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 5803 times.
12915 if(s_version >= 47)
18330 {
18331
1/2
✓ Branch 0 taken 5803 times.
✗ Branch 1 not taken.
5803 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18332 return qe_invalid;
18333 5803 }
18334
2/2
✓ Branch 0 taken 5335 times.
✓ Branch 1 taken 7580 times.
12915 if(s_version >= 53)
18335 {
18336
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.req_level_state, f))
18337 return qe_invalid;
18338
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18339 return qe_invalid;
18340
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18341 return qe_invalid;
18342
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18343 return qe_invalid;
18344
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18345 return qe_invalid;
18346
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18347 return qe_invalid;
18348
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18349 return qe_invalid;
18350
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18351 return qe_invalid;
18352
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetzf(&temp_trigger.player_bounce, f))
18353 return qe_invalid;
18354
1/2
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
5335 if(!p_igetzf(&temp_trigger.req_player_z, f))
18355 return qe_invalid;
18356 5335 }
18357 else
18358 {
18359 7580 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18360 7580 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18361 }
18362
2/2
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 5089 times.
12915 if(s_version >= 54)
18363 {
18364
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_getc(&temp_trigger.req_player_dir,f))
18365 return qe_invalid;
18366
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18367 return qe_invalid;
18368
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18369 return qe_invalid;
18370
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18371 return qe_invalid;
18372
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18373 return qe_invalid;
18374
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.req_player_x, f))
18375 return qe_invalid;
18376
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.req_player_y, f))
18377 return qe_invalid;
18378 5089 }
18379
2/2
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 5089 times.
12915 if(s_version >= 56)
18380 {
18381
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_getc(&temp_trigger.dest_player_dir, f))
18382 return qe_invalid;
18383
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18384 return qe_invalid;
18385
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18386 return qe_invalid;
18387
1/2
✓ Branch 0 taken 5089 times.
✗ Branch 1 not taken.
5089 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18388 return qe_invalid;
18389 5089 }
18390
2/2
✓ Branch 0 taken 8110 times.
✓ Branch 1 taken 4805 times.
12915 if(s_version >= 58)
18391 {
18392
1/2
✓ Branch 0 taken 4805 times.
✗ Branch 1 not taken.
4805 if(!p_igetzf(&temp_trigger.trig_gravity, f))
18393 return qe_invalid;
18394
1/2
✓ Branch 0 taken 4805 times.
✗ Branch 1 not taken.
4805 if(!p_igetzf(&temp_trigger.trig_terminal_v, f))
18395 return qe_invalid;
18396 4805 }
18397 12915 return 0;
18398 12915 }
18399
18400 1495673 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18401 {
18402 byte tempbyte;
18403 word combo_has_flags;
18404
2/2
✓ Branch 0 taken 654185 times.
✓ Branch 1 taken 841488 times.
1495673 if(s_version < 55)
18405 {
18406
1/2
✓ Branch 0 taken 654185 times.
✗ Branch 1 not taken.
654185 if(!p_getc(&tempbyte,f))
18407 return qe_invalid;
18408 654185 combo_has_flags = tempbyte;
18409 654185 }
18410 else
18411 {
18412
1/2
✓ Branch 0 taken 841488 times.
✗ Branch 1 not taken.
841488 if(!p_igetw(&combo_has_flags,f))
18413 return qe_invalid;
18414 }
18415
18416 1495673 temp_combo.clear();
18417
2/2
✓ Branch 0 taken 305822 times.
✓ Branch 1 taken 1189851 times.
1495673 if(combo_has_flags)
18418 {
18419
2/2
✓ Branch 0 taken 521566 times.
✓ Branch 1 taken 668285 times.
1189851 if(combo_has_flags&CHAS_BASIC)
18420 {
18421
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_igetl(&temp_combo.tile,f))
18422 return qe_invalid;
18423 668285 temp_combo.o_tile = temp_combo.tile;
18424
18425
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.flip,f))
18426 return qe_invalid;
18427
18428
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.walk,f))
18429 return qe_invalid;
18430
18431
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.type,f))
18432 return qe_invalid;
18433
18434
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.flag,f))
18435 return qe_invalid;
18436
18437
1/2
✓ Branch 0 taken 668285 times.
✗ Branch 1 not taken.
668285 if(!p_getc(&temp_combo.csets,f))
18438 return qe_invalid;
18439 668285 }
18440
2/2
✓ Branch 0 taken 1186994 times.
✓ Branch 1 taken 2857 times.
1189851 if(combo_has_flags&CHAS_SCRIPT)
18441 {
18442
2/2
✓ Branch 0 taken 2827 times.
✓ Branch 1 taken 30 times.
2857 if (s_version>=41)
18443 {
18444 2827 p_getcstr(&temp_combo.label, f);
18445 2827 }
18446 else
18447 {
18448 char label[12];
18449 30 label[11] = '\0';
18450
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18451
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18452 return qe_invalid;
18453 30 temp_combo.label = label;
18454 }
18455
18456
1/2
✓ Branch 0 taken 2857 times.
✗ Branch 1 not taken.
2857 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18457 2857 auto initd_count = s_version >= 43 ? 8 : 2;
18458
2/2
✓ Branch 0 taken 22676 times.
✓ Branch 1 taken 2857 times.
25533 for ( int32_t q = 0; q < initd_count; q++ )
18459
1/2
✓ Branch 0 taken 22676 times.
✗ Branch 1 not taken.
22676 if(!p_igetl(&temp_combo.initd[q],f))
18460 return qe_invalid;
18461 2857 }
18462
2/2
✓ Branch 0 taken 1062510 times.
✓ Branch 1 taken 127341 times.
1189851 if(combo_has_flags&CHAS_ANIM)
18463 {
18464
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.frames,f))
18465 return qe_invalid;
18466
18467
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.speed,f))
18468 return qe_invalid;
18469
18470
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_igetw(&temp_combo.nextcombo,f))
18471 return qe_invalid;
18472
18473
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.nextcset,f))
18474 return qe_invalid;
18475
18476
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.skipanim,f))
18477 return qe_invalid;
18478
18479
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.skipanimy,f))
18480 return qe_invalid;
18481
18482
1/2
✓ Branch 0 taken 127341 times.
✗ Branch 1 not taken.
127341 if(!p_getc(&temp_combo.animflags,f))
18483 return qe_invalid;
18484 127341 }
18485
2/2
✓ Branch 0 taken 1132522 times.
✓ Branch 1 taken 57329 times.
1189851 if(combo_has_flags&CHAS_ATTRIB)
18486 {
18487
2/2
✓ Branch 0 taken 229316 times.
✓ Branch 1 taken 57329 times.
286645 for ( int32_t q = 0; q < 4; q++ )
18488
1/2
✓ Branch 0 taken 229316 times.
✗ Branch 1 not taken.
229316 if(!p_igetl(&temp_combo.attributes[q],f))
18489 return qe_invalid;
18490
2/2
✓ Branch 0 taken 458632 times.
✓ Branch 1 taken 57329 times.
515961 for ( int32_t q = 0; q < 8; q++ )
18491
1/2
✓ Branch 0 taken 458632 times.
✗ Branch 1 not taken.
458632 if(!p_getc(&temp_combo.attribytes[q],f))
18492 return qe_invalid;
18493
2/2
✓ Branch 0 taken 458632 times.
✓ Branch 1 taken 57329 times.
515961 for ( int32_t q = 0; q < 8; q++ )
18494
1/2
✓ Branch 0 taken 458632 times.
✗ Branch 1 not taken.
458632 if(!p_igetw(&temp_combo.attrishorts[q],f))
18495 return qe_invalid;
18496 57329 }
18497
2/2
✓ Branch 0 taken 1177382 times.
✓ Branch 1 taken 12469 times.
1189851 if(combo_has_flags&CHAS_FLAG)
18498 {
18499
1/2
✓ Branch 0 taken 12469 times.
✗ Branch 1 not taken.
12469 if(!p_igetl(&temp_combo.usrflags,f))
18500 return qe_invalid;
18501
1/2
✓ Branch 0 taken 12469 times.
✗ Branch 1 not taken.
12469 if(!p_igetw(&temp_combo.genflags,f))
18502 return qe_invalid;
18503 12469 }
18504
2/2
✓ Branch 0 taken 1177013 times.
✓ Branch 1 taken 12838 times.
1189851 if(combo_has_flags&CHAS_TRIG)
18505 {
18506 12838 byte count = 1;
18507
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 5258 times.
12838 if(s_version >= 52)
18508
1/2
✓ Branch 0 taken 5258 times.
✗ Branch 1 not taken.
5258 if(!p_getc(&count, f))
18509 return qe_invalid;
18510
18511
2/2
✓ Branch 0 taken 12915 times.
✓ Branch 1 taken 12838 times.
25753 for(byte q = 0; q < count; ++q)
18512 {
18513 12915 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18514 12915 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18515
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(ret)
18516 return ret;
18517 12915 }
18518
18519
2/2
✓ Branch 0 taken 7580 times.
✓ Branch 1 taken 5258 times.
12838 if(s_version < 52)
18520 {
18521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7580 times.
7580 if(!temp_combo.triggers.empty())
18522 7580 temp_combo.only_gentrig = (temp_combo.triggers[0].trigger_flags.get(TRIGFLAG_ONLYGENTRIG)) ? 1 : 0;
18523 7580 }
18524
1/2
✓ Branch 0 taken 5258 times.
✗ Branch 1 not taken.
5258 else if(!p_getc(&temp_combo.only_gentrig,f))
18525 return qe_invalid;
18526 12838 }
18527
2/2
✓ Branch 0 taken 348222 times.
✓ Branch 1 taken 841629 times.
1189851 if(combo_has_flags&CHAS_LIFT)
18528 {
18529
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_igetw(&temp_combo.liftcmb,f))
18530 return qe_invalid;
18531
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftcs,f))
18532 return qe_invalid;
18533
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_igetw(&temp_combo.liftundercmb,f))
18534 return qe_invalid;
18535
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftundercs,f))
18536 return qe_invalid;
18537
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftdmg,f))
18538 return qe_invalid;
18539
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftlvl,f))
18540 return qe_invalid;
18541
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftitm,f))
18542 return qe_invalid;
18543
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftflags,f))
18544 return qe_invalid;
18545
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftgfx,f))
18546 return qe_invalid;
18547
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftsprite,f))
18548 return qe_invalid;
18549
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftsfx,f))
18550 return qe_invalid;
18551
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18552 return qe_invalid;
18553
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.liftbreaksfx,f))
18554 return qe_invalid;
18555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841629 times.
841629 if(s_version >= 34)
18556 {
18557
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.lifthei,f))
18558 return qe_invalid;
18559
1/2
✓ Branch 0 taken 841629 times.
✗ Branch 1 not taken.
841629 if(!p_getc(&temp_combo.lifttime,f))
18560 return qe_invalid;
18561 841629 }
18562
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 841615 times.
841629 if(s_version >= 39)
18563 {
18564
1/2
✓ Branch 0 taken 841615 times.
✗ Branch 1 not taken.
841615 if(!p_getc(&temp_combo.lift_parent_item,f))
18565 return qe_invalid;
18566 841615 }
18567 841629 auto& weap_data = temp_combo.lift_weap_data;
18568
4/4
✓ Branch 0 taken 841512 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 841488 times.
✓ Branch 3 taken 24 times.
841629 if(s_version >= 51 && s_version < 55)
18569 {
18570
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18571 return qe_invalid;
18572
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.glow_shape,f))
18573 return qe_invalid;
18574 24 }
18575
18576
2/2
✓ Branch 0 taken 841488 times.
✓ Branch 1 taken 141 times.
841629 if(s_version >= 55)
18577 {
18578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 841488 times.
841488 if(auto ret = read_weap_data(weap_data, f))
18579 return ret;
18580 841488 }
18581 else
18582 {
18583 141 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18584 141 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18585
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 135 times.
141 switch(pitm.type)
18586 {
18587 case itype_bomb:
18588 case itype_sbomb:
18589 6 weap_data = pitm.weap_data;
18590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18591 {
18592 6 weap_data.flags |= wdata_glow_rad;
18593 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18594 6 }
18595 6 break;
18596 default:
18597 135 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18598 135 weap_data.flags |= wdata_glow_rad;
18599 135 }
18600 141 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18601
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 81 times.
141 if(temp_combo.liftflags & LF_BREAKONSOLID)
18602 60 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18603 }
18604 841629 }
18605
18606
2/2
✓ Branch 0 taken 1156073 times.
✓ Branch 1 taken 33778 times.
1189851 if(combo_has_flags&CHAS_GENERAL)
18607 {
18608
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.speed_mult,f))
18609 return qe_invalid;
18610
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.speed_div,f))
18611 return qe_invalid;
18612
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_igetzf(&temp_combo.speed_add,f))
18613 return qe_invalid;
18614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33778 times.
33778 if(s_version >= 42)
18615 {
18616
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_appear,f))
18617 return qe_invalid;
18618
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_disappear,f))
18619 return qe_invalid;
18620
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_loop,f))
18621 return qe_invalid;
18622
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_walking,f))
18623 return qe_invalid;
18624
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_standing,f))
18625 return qe_invalid;
18626
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_appear,f))
18627 return qe_invalid;
18628
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_disappear,f))
18629 return qe_invalid;
18630
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_walking,f))
18631 return qe_invalid;
18632
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.spr_standing,f))
18633 return qe_invalid;
18634 33778 }
18635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33778 times.
33778 if(s_version >= 44)
18636 {
18637
1/2
✓ Branch 0 taken 33778 times.
✗ Branch 1 not taken.
33778 if(!p_getc(&temp_combo.sfx_tap,f))
18638 return qe_invalid;
18639 33778 }
18640
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 33412 times.
33778 if(s_version >= 49)
18641 {
18642
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_landing,f))
18643 return qe_invalid;
18644 33412 }
18645
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 33412 times.
33778 if(s_version >= 50)
18646 {
18647
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.spr_falling,f))
18648 return qe_invalid;
18649
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.spr_drowning,f))
18650 return qe_invalid;
18651
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18652 return qe_invalid;
18653
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_falling,f))
18654 return qe_invalid;
18655
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_drowning,f))
18656 return qe_invalid;
18657
1/2
✓ Branch 0 taken 33412 times.
✗ Branch 1 not taken.
33412 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18658 return qe_invalid;
18659 33412 }
18660
2/2
✓ Branch 0 taken 4704 times.
✓ Branch 1 taken 29074 times.
33778 if(s_version >= 56)
18661 {
18662
1/2
✓ Branch 0 taken 29074 times.
✗ Branch 1 not taken.
29074 if(!p_igetzf(&temp_combo.z_height,f))
18663 return qe_invalid;
18664
1/2
✓ Branch 0 taken 29074 times.
✗ Branch 1 not taken.
29074 if(!p_igetzf(&temp_combo.z_step_height,f))
18665 return qe_invalid;
18666 29074 }
18667
2/2
✓ Branch 0 taken 4797 times.
✓ Branch 1 taken 28981 times.
33778 if(s_version >= 60)
18668 {
18669
1/2
✓ Branch 0 taken 28981 times.
✗ Branch 1 not taken.
28981 if(!p_getc(&temp_combo.dive_under_level,f))
18670 return qe_invalid;
18671 28981 }
18672 33778 }
18673
1/2
✓ Branch 0 taken 1189851 times.
✗ Branch 1 not taken.
1189851 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18674 {
18675 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18676 return ret;
18677 }
18678 1189851 }
18679 1495673 update_combo(temp_combo, s_version);
18680 1495673 return 0;
18681 1495673 }
18682
18683 481 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18684 {
18685
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18686
18687 481 word section_version=0;
18688 481 word combos_used=0;
18689 int32_t dummy;
18690 byte padding;
18691 481 newcombo temp_combo;
18692
18693
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 480 times.
481 if (!should_skip)
18694 {
18695
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 reset_all_combo_animations();
18696
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 init_combo_classes();
18697
18698
2/2
✓ Branch 0 taken 31334400 times.
✓ Branch 1 taken 480 times.
31334880 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18699
1/2
✓ Branch 0 taken 31334400 times.
✗ Branch 1 not taken.
31334400 combobuf[q].clear();
18700 480 }
18701
18702
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 24 times.
481 if(version > 0x192) //Version info
18703 {
18704
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&section_version,f))
18705 {
18706 return qe_invalid;
18707 }
18708 457 FFCore.quest_format[vCombos] = section_version;
18709
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!read_deprecated_section_cversion(f))
18710 {
18711 return qe_invalid;
18712 }
18713
18714 //section size
18715
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
18716 {
18717 return qe_invalid;
18718 }
18719 457 }
18720
18721
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 288 times.
481 if(section_version > 32) //Cleanup time!
18722 {
18723
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetw(&combos_used,f))
18724 {
18725 return qe_invalid;
18726 }
18727
2/2
✓ Branch 0 taken 1495673 times.
✓ Branch 1 taken 193 times.
1495866 for(int32_t i=0; i<combos_used; i++)
18728 {
18729
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 auto ret = readcombo_loop(f,section_version,temp_combo);
18730
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 if(ret) return ret;
18731
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 if(i>=start_combo)
18732 {
18733
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18734 {
18735 temp_combo.script = 0;
18736 for(int q = 0; q < 8; ++q)
18737 temp_combo.initd[q] = 0;
18738 }
18739
1/2
✓ Branch 0 taken 1495673 times.
✗ Branch 1 not taken.
1495673 combobuf[i] = temp_combo;
18740 1495673 }
18741 1495673 }
18742 193 }
18743 else //Call the old function for all old versions
18744 {
18745
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(ret) return ret; //error, end read
18747 }
18748
18749
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1 times.
481 if (should_skip)
18750 1 return 0;
18751
18752
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 184 times.
480 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18753 {
18754 184 combobuf[0].walk = 0xF0;
18755 184 combobuf[0].type = 0;
18756 184 combobuf[0].flag = 0;
18757 184 }
18758
18759
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 setup_combo_animations();
18760
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 setup_combo_animations2();
18761 480 return 0;
18762 481 }
18763
18764 398 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18765 {
18766 //these are here to bypass compiler warnings about unused arguments
18767 398 Header=Header;
18768 398 version=version;
18769 398 build=build;
18770
18771 int32_t dummy;
18772 398 word sversion=0, c_sversion;
18773
18774 //section version info
18775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(!p_igetw(&sversion,f))
18776 {
18777 return qe_invalid;
18778 }
18779
18780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (sversion > V_COMBOALIASES)
18781 return qe_version;
18782
18783 398 FFCore.quest_format[vComboAliases] = sversion;
18784
18785
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&c_sversion,f))
18786 {
18787 return qe_invalid;
18788 }
18789
18790 //section size
18791
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy,f))
18792 {
18793 return qe_invalid;
18794 }
18795
18796 398 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18797
18798
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 200 times.
398 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18799 {
18800 200 max_num_combo_aliases = MAX250COMBOALIASES;
18801 200 }
18802
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18803 {
18804 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18805 }
18806
18807
2/2
✓ Branch 0 taken 2031616 times.
✓ Branch 1 taken 398 times.
2032014 for(int32_t j=0; j<max_num_combo_aliases; j++)
18808 {
18809 byte width,height,mask,tempcset;
18810 int32_t count;
18811 word tempword;
18812 byte tempbyte;
18813
18814
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_igetw(&tempword,f))
18815 {
18816 return qe_invalid;
18817 }
18818
18819 2031616 combo_aliases[j].combo = tempword;
18820
18821
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&tempbyte,f))
18822 {
18823 return qe_invalid;
18824 }
18825
18826 2031616 combo_aliases[j].cset = tempbyte;
18827
18828
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&width,f))
18829 {
18830 return qe_invalid;
18831 }
18832
18833
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&height,f))
18834 {
18835 return qe_invalid;
18836 }
18837
18838
1/2
✓ Branch 0 taken 2031616 times.
✗ Branch 1 not taken.
2031616 if(!p_getc(&mask,f))
18839 {
18840 return qe_invalid;
18841 }
18842
18843 2031616 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18844
18845 2031616 combo_aliases[j].width = width;
18846 2031616 combo_aliases[j].height = height;
18847 2031616 combo_aliases[j].layermask = mask;
18848 2031616 combo_aliases[j].combos.clear();
18849 2031616 combo_aliases[j].csets.clear();
18850
18851
2/2
✓ Branch 0 taken 2085218 times.
✓ Branch 1 taken 2031616 times.
4116834 for(int32_t k=0; k<count; k++)
18852 {
18853
1/2
✓ Branch 0 taken 2085218 times.
✗ Branch 1 not taken.
2085218 if(!p_igetw(&tempword,f))
18854 {
18855 return qe_invalid;
18856 }
18857
18858 2085218 combo_aliases[j].combos[k] = tempword;
18859 2085218 }
18860
18861
2/2
✓ Branch 0 taken 2085218 times.
✓ Branch 1 taken 2031616 times.
4116834 for(int32_t k=0; k<count; k++)
18862 {
18863
1/2
✓ Branch 0 taken 2085218 times.
✗ Branch 1 not taken.
2085218 if(!p_getc(&tempcset,f))
18864 {
18865 return qe_invalid;
18866 }
18867
18868 2085218 combo_aliases[j].csets[k] = tempcset;
18869 2085218 }
18870 2031616 }
18871
18872 //Combo pools!
18873 398 word num_combo_pools = 0;
18874
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 193 times.
398 if(sversion >= 4)
18875 {
18876
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 if(!p_igetw(&num_combo_pools,f))
18877 {
18878 return qe_invalid;
18879 }
18880 193 }
18881
18882
2/2
✓ Branch 0 taken 3260416 times.
✓ Branch 1 taken 398 times.
3260814 for(combo_pool& pool : combo_pools)
18883 {
18884 3260416 pool.clear();
18885 }
18886
18887 398 combo_pool temp_cpool;
18888
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 398 times.
888 for(word cp = 0; cp < num_combo_pools; ++cp)
18889 {
18890 490 int32_t num_combos_in_pool = 0;
18891
2/4
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490 times.
✗ Branch 3 not taken.
490 if(!p_igetl(&num_combos_in_pool,f))
18892 {
18893 return qe_invalid;
18894 }
18895
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 96 times.
490 if(num_combos_in_pool < 1) continue; //nothing to read
18896
18897
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 temp_cpool.clear();
18898
18899 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18900
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 1775 times.
2169 for(auto q = 0; q < num_combos_in_pool; ++q)
18901 {
18902
2/4
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1775 times.
✗ Branch 3 not taken.
1775 if(!p_igetl(&cp_cid,f))
18903 {
18904 return qe_invalid;
18905 }
18906
2/4
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1775 times.
✗ Branch 3 not taken.
1775 if(!p_getc(&cp_cs,f))
18907 {
18908 return qe_invalid;
18909 }
18910
2/4
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1775 times.
✗ Branch 3 not taken.
1775 if(!p_igetw(&cp_quant,f))
18911 {
18912 return qe_invalid;
18913 }
18914
1/2
✓ Branch 0 taken 1775 times.
✗ Branch 1 not taken.
1775 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18915 1775 }
18916
18917
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 combo_pools[cp] = temp_cpool;
18918 394 }
18919
18920 //Autocombos!
18921 398 word num_combo_autos = 0;
18922
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 217 times.
398 if (sversion >= 5)
18923 {
18924
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_igetw(&num_combo_autos, f))
18925 {
18926 return qe_invalid;
18927 }
18928 181 }
18929
18930
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 3260416 times.
3260814 for (combo_auto& cauto : combo_autos)
18931 {
18932
1/2
✓ Branch 0 taken 3260416 times.
✗ Branch 1 not taken.
3260416 cauto.clear(true);
18933 }
18934
18935
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 combo_auto temp_cauto;
18936
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 398 times.
530 for (word ca = 0; ca < num_combo_autos; ++ca)
18937 {
18938 byte type;
18939 int32_t display_cid, erase_cid;
18940 byte flags, arg;
18941
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_getc(&type, f))
18942 {
18943 return qe_invalid;
18944 }
18945
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_igetl(&display_cid, f))
18946 {
18947 return qe_invalid;
18948 }
18949
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_igetl(&erase_cid, f))
18950 {
18951 return qe_invalid;
18952 }
18953
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_getc(&flags, f))
18954 {
18955 return qe_invalid;
18956 }
18957
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_getc(&arg, f))
18958 {
18959 return qe_invalid;
18960 }
18961 132 int32_t num_combos_in_cauto = 0;
18962
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if (!p_igetl(&num_combos_in_cauto, f))
18963 {
18964 return qe_invalid;
18965 }
18966
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 21 times.
132 if (num_combos_in_cauto < 1) continue; //nothing to read
18967
18968
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.clear();
18969
18970
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setType(type);
18971
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setDisplay(display_cid);
18972
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setEraseCombo(erase_cid);
18973
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setFlags(flags);
18974
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 temp_cauto.setArg(arg);
18975
18976 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18977
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 2437 times.
2548 for (auto q = 0; q < num_combos_in_cauto; ++q)
18978 {
18979
2/4
✓ Branch 0 taken 2437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
2437 if (!p_getc(&ca_ctype, f))
18980 {
18981 return qe_invalid;
18982 }
18983
2/4
✓ Branch 0 taken 2437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
2437 if (!p_igetl(&ca_cid, f))
18984 {
18985 return qe_invalid;
18986 }
18987
1/2
✓ Branch 0 taken 2437 times.
✗ Branch 1 not taken.
2437 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18988 2437 }
18989
18990
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 combo_autos[ca] = temp_cauto;
18991 111 }
18992
18993 398 return 0;
18994 398 }
18995
18996 804 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18997 {
18998
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18999
19000 //these are here to bypass compiler warnings about unused arguments
19001 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
19002 //Capitalized cause it'll save you a headache. -Deedee
19003 804 start_cset=start_cset;
19004 804 max_csets=max_csets;
19005 804 word s_version=0;
19006
19007 miscQdata temp_misc;
19008 804 memcpy(&temp_misc, Misc, sizeof(temp_misc));
19009
19010 byte temp_colordata[48];
19011 char temp_palname[PALNAMESIZE+1];
19012
19013 int32_t dummy;
19014 word palcycles;
19015
19016
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(version > 0x192)
19017 {
19018 //section version info
19019
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&s_version,f))
19020 {
19021 return qe_invalid;
19022 }
19023
19024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if (s_version > V_CSETS)
19025 return qe_version;
19026
19027 780 FFCore.quest_format[vCSets] = s_version;
19028
19029
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&dummy,f))
19030 {
19031 return qe_invalid;
19032 }
19033
19034 //section size
19035
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&dummy,f))
19036 {
19037 return qe_invalid;
19038 }
19039 780 }
19040
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 198 times.
804 if (s_version < 5)
19041 {
19042
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 588 times.
✓ Branch 2 taken 582 times.
✓ Branch 3 taken 6 times.
606 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
19043
19044 //finally... section data
19045 606 int32_t q = 0;
19046 606 int32_t p = -15;
19047
2/2
✓ Branch 0 taken 145440 times.
✓ Branch 1 taken 606 times.
146046 for(int32_t i=0; i<oldpdTOTAL; ++i)
19048 {
19049 145440 memset(temp_colordata, 0, 48);
19050
19051
1/2
✓ Branch 0 taken 145440 times.
✗ Branch 1 not taken.
145440 if(!pfread(temp_colordata,48,f))
19052 {
19053 return qe_invalid;
19054 }
19055
19056
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 145200 times.
145440 if (should_skip)
19057 240 continue;
19058
19059 145200 memcpy(&colordata[q*48], temp_colordata, 48);
19060
19061 145200 ++q;
19062
8/8
✓ Branch 0 taken 135520 times.
✓ Branch 1 taken 9680 times.
✓ Branch 2 taken 10285 times.
✓ Branch 3 taken 125235 times.
✓ Branch 4 taken 1210 times.
✓ Branch 5 taken 9075 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1174 times.
145200 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
19063 {
19064
1/2
✓ Branch 0 taken 10249 times.
✗ Branch 1 not taken.
10249 if (s_version < 5) //Bumping up the size of level palettes
19065 {
19066 10249 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19067 10249 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19068 10249 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19069 10249 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19070 10249 q+=4;
19071 10249 }
19072 else
19073 {
19074 for(int m = 0; m < 4; ++m)
19075 {
19076 memset(temp_colordata, 0, 48);
19077 if(!pfread(temp_colordata,48,f))
19078 {
19079 return qe_invalid;
19080 }
19081 memcpy(&colordata[q*48], temp_colordata, 48);
19082 ++q;
19083 }
19084 }
19085 10249 }
19086 145200 ++p;
19087 145200 }
19088
19089
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 588 times.
606 if(RealOldVerion)
19090 {
19091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19092 {
19093 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19094 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19095 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19096 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19097 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19098 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19099 18 }
19100 18 }
19101 else
19102 {
19103 588 memset(temp_colordata, 0, 48);
19104
19105
2/2
✓ Branch 0 taken 1842204 times.
✓ Branch 1 taken 588 times.
1842792 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19106 {
19107
1/2
✓ Branch 0 taken 1842204 times.
✗ Branch 1 not taken.
1842204 if(!pfread(temp_colordata,48,f))
19108 {
19109 return qe_invalid;
19110 }
19111
19112
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1839071 times.
1842204 if (should_skip)
19113 3133 continue;
19114
19115 1839071 memcpy(&colordata[q*48], temp_colordata, 48);
19116
19117 1839071 ++q;
19118
7/8
✓ Branch 0 taken 1839071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141467 times.
✓ Branch 3 taken 1697604 times.
✓ Branch 4 taken 1174 times.
✓ Branch 5 taken 140293 times.
✓ Branch 6 taken 1046 times.
✓ Branch 7 taken 128 times.
1839071 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19119 {
19120
1/2
✓ Branch 0 taken 141339 times.
✗ Branch 1 not taken.
141339 if (s_version < 5) //Bumping up the size of level palettes
19121 {
19122 141339 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19123 141339 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19124 141339 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19125 141339 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19126 141339 q+=4;
19127 141339 }
19128 else
19129 {
19130 for(int m = 0; m < 4; ++m)
19131 {
19132 memset(temp_colordata, 0, 48);
19133 if(!pfread(temp_colordata,48,f))
19134 {
19135 return qe_invalid;
19136 }
19137 memcpy(&colordata[q*48], temp_colordata, 48);
19138 ++q;
19139 }
19140 }
19141 141339 }
19142 1839071 ++p;
19143 1839071 }
19144
19145
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 523 times.
588 if(s_version < 4)
19146 {
19147
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19148 {
19149 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19150 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19151 64 }
19152 65 }
19153 else
19154 {
19155
2/2
✓ Branch 0 taken 1740544 times.
✓ Branch 1 taken 523 times.
1741067 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19156 {
19157
1/2
✓ Branch 0 taken 1740544 times.
✗ Branch 1 not taken.
1740544 if(!pfread(temp_colordata,48,f))
19158 {
19159 return qe_invalid;
19160 }
19161
19162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1740544 times.
1740544 if (should_skip)
19163 continue;
19164
19165 1740544 memcpy(&colordata[q*48], temp_colordata, 48);
19166 1740544 ++q;
19167
5/6
✓ Branch 0 taken 1740544 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133888 times.
✓ Branch 3 taken 1606656 times.
✓ Branch 4 taken 1046 times.
✓ Branch 5 taken 132842 times.
1740544 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19168 {
19169
1/2
✓ Branch 0 taken 132842 times.
✗ Branch 1 not taken.
132842 if (s_version < 5) //Bumping up the size of level palettes
19170 {
19171 132842 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19172 132842 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19173 132842 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19174 132842 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19175 132842 q+=4;
19176 132842 }
19177 else
19178 {
19179 for(int m = 0; m < 4; ++m)
19180 {
19181 memset(temp_colordata, 0, 48);
19182 if(!pfread(temp_colordata,48,f))
19183 {
19184 return qe_invalid;
19185 }
19186 memcpy(&colordata[q*48], temp_colordata, 48);
19187 ++q;
19188 }
19189 }
19190 132842 }
19191 1740544 ++p;
19192 1740544 }
19193
19194 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19195 }
19196 }
19197 606 }
19198 else
19199 {
19200
2/2
✓ Branch 0 taken 1732302 times.
✓ Branch 1 taken 198 times.
1732500 for(int32_t i=0; i<pdTOTAL255; ++i)
19201 {
19202 1732302 memset(temp_colordata, 0, 48);
19203
19204
1/2
✓ Branch 0 taken 1732302 times.
✗ Branch 1 not taken.
1732302 if(!pfread(temp_colordata,48,f))
19205 {
19206 return qe_invalid;
19207 }
19208
19209 1732302 memcpy(&colordata[i*48], temp_colordata, 48);
19210 1732302 }
19211 }
19212
19213
4/4
✓ Branch 0 taken 803 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 153 times.
✓ Branch 3 taken 650 times.
804 if (!should_skip && s_version < 6)
19214 {
19215
2/2
✓ Branch 0 taken 272968800 times.
✓ Branch 1 taken 650 times.
272969450 for (int i = 0; i < psTOTAL255; i++)
19216 {
19217 272968800 colordata[i] = _rgb_scale_6[colordata[i]];
19218 272968800 }
19219 650 }
19220
19221
5/6
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 780 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
804 if((version < 0x192)||((version == 0x192)&&(build<76)))
19222 {
19223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19224 18 init_palnames();
19225 18 }
19226 else
19227 {
19228 786 int32_t palnamestoread = 0;
19229
19230
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 721 times.
786 if(s_version < 3)
19231 65 palnamestoread = OLDMAXLEVELS;
19232 else
19233 721 palnamestoread = 512;
19234
19235
2/2
✓ Branch 0 taken 385792 times.
✓ Branch 1 taken 786 times.
386578 for(int32_t i=0; i<palnamestoread; ++i)
19236 {
19237
1/2
✓ Branch 0 taken 385792 times.
✗ Branch 1 not taken.
385792 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19238 {
19239 return qe_invalid;
19240 }
19241
19242
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 385536 times.
385792 if (!should_skip)
19243 385536 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19244 385792 }
19245
19246
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 785 times.
786 if (should_skip)
19247 1 return 0;
19248
19249
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 785 times.
17169 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19250 {
19251 16384 memset(palnames[i], 0, PALNAMESIZE);
19252 16384 }
19253 }
19254
19255
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 780 times.
803 if(version > 0x192)
19256 {
19257
2/2
✓ Branch 0 taken 199680 times.
✓ Branch 1 taken 780 times.
200460 for(int32_t i=0; i<256; i++)
19258 {
19259
2/2
✓ Branch 0 taken 599040 times.
✓ Branch 1 taken 199680 times.
798720 for(int32_t j=0; j<3; j++)
19260 {
19261 599040 temp_misc.cycles[i][j].first=0;
19262 599040 temp_misc.cycles[i][j].count=0;
19263 599040 temp_misc.cycles[i][j].speed=0;
19264 599040 }
19265 199680 }
19266
19267
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&palcycles,f))
19268 {
19269 return qe_invalid;
19270 }
19271
19272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if (palcycles > NUM_PAL_CYCLES)
19273 {
19274 return qe_invalid;
19275 }
19276
19277
2/2
✓ Branch 0 taken 22039 times.
✓ Branch 1 taken 780 times.
22819 for(int32_t i=0; i<palcycles; i++)
19278 {
19279
2/2
✓ Branch 0 taken 66117 times.
✓ Branch 1 taken 22039 times.
88156 for(int32_t j=0; j<3; j++)
19280 {
19281
1/2
✓ Branch 0 taken 66117 times.
✗ Branch 1 not taken.
66117 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19282 {
19283 return qe_invalid;
19284 }
19285 66117 }
19286
19287
2/2
✓ Branch 0 taken 66117 times.
✓ Branch 1 taken 22039 times.
88156 for(int32_t j=0; j<3; j++)
19288 {
19289
1/2
✓ Branch 0 taken 66117 times.
✗ Branch 1 not taken.
66117 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19290 {
19291 return qe_invalid;
19292 }
19293 66117 }
19294
19295
2/2
✓ Branch 0 taken 66117 times.
✓ Branch 1 taken 22039 times.
88156 for(int32_t j=0; j<3; j++)
19296 {
19297
1/2
✓ Branch 0 taken 66117 times.
✗ Branch 1 not taken.
66117 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19298 {
19299 return qe_invalid;
19300 }
19301 66117 }
19302 22039 }
19303
19304 780 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19305 780 }
19306
19307 803 return 0;
19308 804 }
19309
19310 804 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19311 {
19312
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19313
19314 804 int32_t tiles_used=0;
19315 804 word section_version = 0;
19316 804 int32_t section_size= 0;
19317 804 byte *temp_tile = new byte[tilesize(tf32Bit)];
19318
19319 //Tile Expansion
19320 //if ( version >= 0x254 && build >= 41 )
19321
4/4
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 600 times.
804 if (version < 0x254 && build < 41)
19322 {
19323 600 max_tiles = ZC250MAXTILES;
19324 600 }
19325
19326
19327
2/6
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19328 {
19329 if(!init_tiles_for_190(true, Header))
19330 {
19331 al_trace("Unable to initialize tiles\n");
19332 }
19333
19334 delete[] temp_tile;
19335 temp_tile=NULL;
19336 return 0;
19337 }
19338 else
19339 {
19340
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 780 times.
804 if(version > 0x192)
19341 {
19342 //section version info
19343
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetw(&section_version,f))
19344 {
19345 delete[] temp_tile;
19346 return qe_invalid;
19347 }
19348
19349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if (section_version > V_TILES)
19350 return qe_version;
19351
19352 780 FFCore.quest_format[vTiles] = section_version;
19353
19354
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!read_deprecated_section_cversion(f))
19355 {
19356 delete[] temp_tile;
19357 return qe_invalid;
19358 }
19359
19360 //section size
19361
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 if(!p_igetl(&section_size,f))
19362 {
19363 delete[] temp_tile;
19364 return qe_invalid;
19365 }
19366 780 }
19367
19368 //if ( build < 41 )
19369 //{
19370 // tiles_used = ZC250MAXTILES;
19371 //}
19372
19373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(version < 0x174)
19374 {
19375 tiles_used=TILES_PER_PAGE*4;
19376 } //no expanded tile space
19377
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 786 times.
804 else if(version < 0x191)
19378 {
19379 18 tiles_used=OLDMAXTILES;
19380 18 }
19381 else
19382 {
19383 //finally... section data
19384
3/4
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
786 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19385 {
19386
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_igetl(&tiles_used,f))
19387 {
19388 delete[] temp_tile;
19389 return qe_invalid;
19390 }
19391 198 }
19392 else
19393 {
19394
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(!p_igetw(&tiles_used,f))
19395 {
19396 delete[] temp_tile;
19397 return qe_invalid;
19398 }
19399 }
19400 }
19401
19402
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tiles_used=zc_min(tiles_used, max_tiles);
19403
19404 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19405 //if ( version < 0x254 && build < 41 )
19406
3/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 198 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if ( version < 0x254 || (version == 0x254 && build < 41) )
19407 //if ( build < 41 )
19408 {
19409
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19410 606 }
19411 else //2.55
19412 {
19413
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19414 }
19415
19416 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19417
19418
19419
2/2
✓ Branch 0 taken 18501702 times.
✓ Branch 1 taken 804 times.
18502506 for(int32_t i=0; i<tiles_used; ++i)
19420 {
19421 18501702 byte format=tf4Bit;
19422 18501702 memset(temp_tile, 0, tilesize(tf32Bit));
19423
19424
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 15516246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18501702 if((version>0x211)||((version==0x211)&&(build>4)))
19425 {
19426
1/2
✓ Branch 0 taken 15516246 times.
✗ Branch 1 not taken.
15516246 if(!p_getc(&format,f))
19427 {
19428 delete[] temp_tile;
19429 return qe_invalid;
19430 }
19431 15516246 }
19432
4/4
✓ Branch 0 taken 7573472 times.
✓ Branch 1 taken 10928230 times.
✓ Branch 2 taken 3466558 times.
✓ Branch 3 taken 4106914 times.
18501702 if(section_version > 2 && !format)
19433 {
19434 4106914 reset_tile(buf,start_tile+i,tf4Bit);
19435 4106914 continue;
19436 }
19437
19438
2/2
✓ Branch 0 taken 13902064 times.
✓ Branch 1 taken 492724 times.
14394788 int size = format == tf4Bit ? 128 : tilesize(format);
19439
1/2
✓ Branch 0 taken 14394788 times.
✗ Branch 1 not taken.
14394788 if(!pfread(temp_tile,size,f))
19440 {
19441 delete[] temp_tile;
19442 return qe_invalid;
19443 }
19444
19445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14394788 times.
14394788 if (should_skip)
19446 continue;
19447
19448 14394788 buf[start_tile+i].format=format;
19449
19450
2/2
✓ Branch 0 taken 14190903 times.
✓ Branch 1 taken 203885 times.
14394788 if(buf[start_tile+i].data)
19451 {
19452 14190903 free(buf[start_tile+i].data);
19453 14190903 buf[start_tile+i].data=NULL;
19454 14190903 }
19455
19456 14394788 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19457
19458
2/2
✓ Branch 0 taken 13902064 times.
✓ Branch 1 taken 492724 times.
14394788 if (format == tf4Bit)
19459 {
19460 byte temp[256];
19461 13902064 byte *si = temp_tile + 128;
19462 13902064 byte *di = temp + 256;
19463
19464
2/2
✓ Branch 0 taken 1779464192 times.
✓ Branch 1 taken 13902064 times.
1793366256 for(int i=127; i>=0; --i)
19465 {
19466 1779464192 (*(--di)) = (*(--si)) >> 4;
19467 1779464192 (*(--di)) = (*si) & 15;
19468 1779464192 }
19469
19470 13902064 memcpy(buf[start_tile+i].data,temp,256);
19471 13902064 }
19472 else
19473 {
19474 492724 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19475 }
19476 14394788 }
19477 }
19478
19479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (should_skip)
19480 return 0;
19481
19482
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
804 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19483 {
19484
2/2
✓ Branch 0 taken 90281880 times.
✓ Branch 1 taken 606 times.
90282486 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19485 {
19486
19487 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19488 90281880 reset_tile(buf,q,tf4Bit);
19489
19490
19491 /*
19492
19493 byte tempbyte;
19494 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19495 {
19496 tempbyte=buf[ZC250MAXTILES-1].data[i];
19497 buf[q].data[i] = tempbyte;
19498 }
19499 //int32_t temp = tempbyte=buf[130].data[i];
19500 //buf[q].data = buf[ZC250MAXTILES-1].data;
19501 */
19502 //reset_tile(buf,q,tf4Bit);
19503 90281880 }
19504
19505 606 }
19506
19507
4/6
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
804 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19508 {
19509
2/2
✓ Branch 0 taken 30244486 times.
✓ Branch 1 taken 606 times.
30245092 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19510 {
19511 30244486 reset_tile(buf,i,tf4Bit);
19512 30244486 }
19513 606 }
19514 else
19515 {
19516
2/2
✓ Branch 0 taken 34323812 times.
✓ Branch 1 taken 198 times.
34324010 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19517 {
19518 34323812 reset_tile(buf,i,tf4Bit);
19519 34323812 }
19520 }
19521
19522
5/6
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
804 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19523 {
19524
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19525 {
19526 byte tempbyte;
19527 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19528
19529
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19530 {
19531 1536 tempbyte=buf[23].data[i];
19532 1536 buf[23].data[i]=buf[24].data[i];
19533 1536 buf[24].data[i]=buf[25].data[i];
19534 1536 buf[25].data[i]=buf[26].data[i];
19535 1536 buf[26].data[i]=tempbyte;
19536 1536 }
19537 //swim tiles are out of order, too, but nobody cared? -Z
19538
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19539 {
19540 1536 tempbyte=buf[floattile+11].data[i];
19541 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19542 1536 buf[floattile+12].data[i]=tempbyte;
19543 1536 }
19544 6 }
19545 24 }
19546
19547
3/6
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19548 {
19549
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19550 {
19551 byte tempbyte;
19552
19553
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19554 {
19555 5632 tempbyte=buf[130].data[i];
19556 5632 buf[130].data[i]=buf[132].data[i];
19557 5632 buf[132].data[i]=tempbyte;
19558
19559 5632 tempbyte=buf[131].data[i];
19560 5632 buf[131].data[i]=buf[133].data[i];
19561 5632 buf[133].data[i]=tempbyte;
19562 5632 }
19563 22 }
19564 83 }
19565
19566 804 al_trace("Registering blank tiles\n");
19567 804 register_blank_tiles();
19568
19569 //memset(temp_tile, 0, tilesize(tf32Bit));
19570
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 delete[] temp_tile;
19571 804 temp_tile=NULL;
19572 804 return 0;
19573 804 }
19574
19575 480 int32_t readmidis(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19576 {
19577
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19578
19579 static byte fake_midi_flags[32];
19580
19581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19582 int32_t dummy;
19583 word dummy2;
19584 // zcmidi_ temp_midi;
19585 int32_t tunes_to_read;
19586 480 int32_t tune_count=0;
19587 480 word section_version=0;
19588 480 zctune temp;
19589
19590
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version < 0x193)
19591 {
19592 // mf=Header->data_flags+ZQ_MIDIS2;
19593
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19594 {
19595 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19596 22 }
19597 else
19598 {
19599 1 tunes_to_read=MAXCUSTOMTUNES;
19600 }
19601 23 }
19602 else
19603 {
19604 //section version info
19605
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&section_version,f))
19606 {
19607 return qe_invalid;
19608 }
19609
19610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (section_version > V_MIDIS)
19611 return qe_version;
19612
19613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (!should_skip)
19614 457 FFCore.quest_format[vMIDIs] = section_version;
19615
19616
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy2,f))
19617 {
19618 return qe_invalid;
19619 }
19620
19621 //section size
19622
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
19623 {
19624 return qe_invalid;
19625 }
19626
19627 //finally... section data
19628
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!pfread(midi_flags,sizeof(midi_flags),f))
19629 {
19630 return qe_invalid;
19631 }
19632
19633 457 tunes_to_read=MAXCUSTOMTUNES;
19634 }
19635
19636
2/2
✓ Branch 0 taken 120960 times.
✓ Branch 1 taken 480 times.
121440 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19637 {
19638
2/2
✓ Branch 0 taken 10210 times.
✓ Branch 1 taken 110750 times.
120960 if(get_bit(mf, i))
19639 {
19640 10210 ++tune_count;
19641 10210 }
19642 120960 }
19643
19644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (!should_skip)
19645 480 reset_tunes(tunes); //reset_midis(midis);
19646
19647
2/2
✓ Branch 0 taken 116120 times.
✓ Branch 1 taken 480 times.
116600 for(int32_t i=0; i<tunes_to_read; i++)
19648 {
19649 116120 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19650
19651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116120 times.
116120 if (!should_skip)
19652 116120 tunes[i].reset(); // reset_midi(midis+i);
19653
19654
2/2
✓ Branch 0 taken 105910 times.
✓ Branch 1 taken 10210 times.
116120 if(get_bit(mf,i))
19655 {
19656
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version < 4)
19657 {
19658
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19659 {
19660 return qe_invalid;
19661 }
19662 2663 }
19663 else
19664 {
19665
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19666 {
19667 return qe_invalid;
19668 }
19669 }
19670
19671
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.start,f))
19672 {
19673 return qe_invalid;
19674 }
19675
19676
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.loop_start,f))
19677 {
19678 return qe_invalid;
19679 }
19680
19681
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetl(&temp.loop_end,f))
19682 {
19683 return qe_invalid;
19684 }
19685
19686
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetw(&temp.loop,f))
19687 {
19688 return qe_invalid;
19689 }
19690
19691
1/2
✓ Branch 0 taken 10210 times.
✗ Branch 1 not taken.
10210 if(!p_igetw(&temp.volume,f))
19692 {
19693 return qe_invalid;
19694 }
19695
19696
2/2
✓ Branch 0 taken 9961 times.
✓ Branch 1 taken 249 times.
10210 if(Header->zelda_version < 0x193)
19697 {
19698
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19699 {
19700 return qe_invalid;
19701 }
19702 249 }
19703
19704
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version >= 3)
19705 {
19706
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19707 {
19708 return qe_invalid;
19709 }
19710 7547 }
19711
19712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10210 times.
10210 if (!should_skip)
19713 10210 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19714
19715
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7547 times.
10210 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19716 {
19717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19718 {
19719 if (read_midi(f)==NULL)
19720 {
19721 return qe_invalid;
19722 }
19723
19724 continue;
19725 }
19726
19727 // old format - a midi is a midi
19728
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19729 {
19730 return qe_invalid;
19731 }
19732 2663 }
19733 else
19734 {
19735 byte format;
19736
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if(!pfread(&format,sizeof(format),f))
19737 {
19738 return qe_invalid;
19739 }
19740
19741 // MIDI is the only format saved here.
19742 // Never did more than MIDI for a zctune, and no plans to now.
19743
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if (format != MFORMAT_MIDI)
19744 {
19745 return qe_invalid;
19746 }
19747
19748 7547 tunes[i].data = read_midi(f);
19749
1/2
✓ Branch 0 taken 7547 times.
✗ Branch 1 not taken.
7547 if (!tunes[i].data)
19750 {
19751 return qe_invalid;
19752 }
19753 }
19754 10210 }
19755 116120 }
19756
19757 480 return 0;
19758 480 }
19759
19760 480 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19761 {
19762
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19763
19764 int32_t dummy;
19765 ZCHEATS tempzcheats;
19766 480 char temp_use_cheats=1;
19767 480 memset(&tempzcheats, 0, sizeof(tempzcheats));
19768 480 word s_version = 0;
19769
19770
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 457 times.
480 if(Header->zelda_version > 0x192)
19771 {
19772 //section version info
19773
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&s_version,f))
19774 {
19775 return qe_invalid;
19776 }
19777
19778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if (s_version > V_CHEATS)
19779 return qe_version;
19780
19781 457 FFCore.quest_format[vCheats] = s_version;
19782
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetw(&dummy,f))
19783 {
19784 return qe_invalid;
19785 }
19786
19787 //section size
19788
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(!p_igetl(&dummy,f))
19789 {
19790 return qe_invalid;
19791 }
19792
19793 //finally... section data
19794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(!p_getc(&temp_use_cheats,f))
19795 {
19796 return qe_invalid;
19797 }
19798 457 }
19799
19800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(Header->data_flags[ZQ_CHEATS2])
19801 {
19802
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_igetl(&tempzcheats.flags,f))
19803 {
19804 return qe_invalid;
19805 }
19806
19807
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19808 {
19809 return qe_invalid;
19810 }
19811 480 }
19812
19813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if (should_skip)
19814 return 0;
19815
19816 480 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19817 480 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19818
19819 480 return 0;
19820 480 }
19821
19822 299 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19823 {
19824
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
299 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19825
19826 byte padding, tempbyte;
19827
19828 // Legacy item properties (now integrated into itemdata)
19829 byte sword_hearts[4];
19830 byte beam_hearts[4];
19831 299 byte beam_percent=0;
19832 word beam_power[4];
19833 299 byte hookshot_length=99;
19834 299 byte hookshot_links=100;
19835 299 byte longshot_length=99;
19836 299 byte longshot_links=100;
19837 299 byte moving_fairy_hearts=3;
19838 299 byte moving_fairy_heart_percent=0;
19839 299 byte stationary_fairy_hearts=3;
19840 299 byte stationary_fairy_heart_percent=0;
19841 299 byte moving_fairy_magic=0;
19842 299 byte moving_fairy_magic_percent=0;
19843 299 byte stationary_fairy_magic=0;
19844 299 byte stationary_fairy_magic_percent=0;
19845 299 byte blue_potion_hearts=100;
19846 299 byte blue_potion_heart_percent=1;
19847 299 byte red_potion_hearts=100;
19848 299 byte red_potion_heart_percent=1;
19849 299 byte blue_potion_magic=100;
19850 299 byte blue_potion_magic_percent=1;
19851 299 byte red_potion_magic=100;
19852 299 byte red_potion_magic_percent=1;
19853
19854 299 byte bomb_ratio = 4;
19855
19856 299 subscr_mode = 0;
19857
19858 /* HIGHLY UNORTHODOX UPDATING THING, by L
19859 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19860 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19861 * changing from 13 to 14.
19862 */
19863
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 14)
19864 82 fixpolsvoice=true;
19865
19866 /* End highly unorthodox updating thing */
19867
19868
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 111 times.
299 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19869 111 temp_zinit.jump_hero_layer_threshold=0;
19870
19871
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
299 if(s_version >= 10)
19872 {
19873 char temp;
19874
19875 //new-style items
19876
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 217 times.
55769 for(int32_t j=0; j<256; j++)
19877 {
19878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(!p_getc(&temp,f))
19879 return qe_invalid;
19880
19881 55552 temp_zinit.set_item(j, temp != 0);
19882 55552 }
19883 217 }
19884
19885
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19886 {
19887 char temp;
19888
19889 //finally... section data
19890
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
19891 //new only
19892
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19893 {
19894 //OLD-style items... sigh
19895
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 60 times.
277 if(s_version < 10)
19896 {
19897
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19898 {
19899 return qe_invalid;
19900 }
19901
19902 60 temp_zinit.set_item(iRaft, temp != 0);
19903
19904
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19905 {
19906 return qe_invalid;
19907 }
19908
19909 60 temp_zinit.set_item(iLadder, temp != 0);
19910
19911
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19912 {
19913 return qe_invalid;
19914 }
19915
19916 60 temp_zinit.set_item(iBook, temp != 0);
19917
19918
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19919 {
19920 return qe_invalid;
19921 }
19922
19923 60 temp_zinit.set_item(iMKey, temp != 0);
19924
19925
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19926 {
19927 return qe_invalid;
19928 }
19929
19930 60 temp_zinit.set_item(iFlippers, temp != 0);
19931
19932
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19933 {
19934 return qe_invalid;
19935 }
19936
19937 60 temp_zinit.set_item(iBoots, temp != 0);
19938 60 }
19939 277 }
19940
19941
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
19942 {
19943 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19944
19945
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19946 {
19947 return qe_invalid;
19948 }
19949
19950
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19951 {
19952 return qe_invalid;
19953 }
19954
19955
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19956 {
19957 return qe_invalid;
19958 }
19959
19960
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19961 {
19962 return qe_invalid;
19963 }
19964
19965
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19966 {
19967 return qe_invalid;
19968 }
19969
19970
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19971 {
19972 return qe_invalid;
19973 }
19974
19975
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19976 {
19977 return qe_invalid;
19978 }
19979
19980 //old only
19981
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19982 {
19983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19985
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19990 4 }
19991
19992 //rings start at level 2... wtf
19993 //account for this -DD
19994 64 tempring <<= 1;
19995 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19996 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19997 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19998 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19999 //bracelet ALSO starts at level 2 :-( -DD
20000 64 tempbracelet<<=1;
20001 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
20002 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
20003 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
20004
20005 //new only
20006
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
20007 {
20008
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20009 {
20010
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20011 {
20012 return qe_invalid;
20013 }
20014 32 }
20015 1 }
20016
20017 char tempcandle, tempboomerang, temparrow, tempwhistle;
20018
20019
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
20020 {
20021 return qe_invalid;
20022 }
20023
20024
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
20025 {
20026 return qe_invalid;
20027 }
20028
20029
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
20030 {
20031 return qe_invalid;
20032 }
20033
20034
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
20035 {
20036 return qe_invalid;
20037 }
20038
20039 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
20040
20041
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
20042 {
20043 return qe_invalid;
20044 }
20045
20046 //old only
20047
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20048 {
20049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
20050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
20051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
20052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
20053 4 }
20054
20055 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
20056 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
20057 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
20058 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
20059 //What about the potion...?
20060
20061 64 }
20062
20063
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20064 {
20065 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
20066 //to jab out my eye...
20067
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20068 return qe_invalid;
20069 264 temp_zinit.counter[crBOMBS] = padding;
20070
20071
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20072 return qe_invalid;
20073 264 temp_zinit.counter[crSBOMBS] = padding;
20074 264 }
20075
20076 //Back to more OLD item code
20077
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20078 {
20079
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
20080 //new only
20081
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20082 {
20083
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20084 {
20085 return qe_invalid;
20086 }
20087
20088 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20089
20090
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20091 {
20092 return qe_invalid;
20093 }
20094
20095 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20096
20097
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20098 {
20099 return qe_invalid;
20100 }
20101
20102 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20103
20104
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20105 {
20106 return qe_invalid;
20107 }
20108
20109 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20110
20111
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20112 {
20113 return qe_invalid;
20114 }
20115
20116 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20117
20118
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20119 {
20120 return qe_invalid;
20121 }
20122
20123 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20124
20125
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20126 {
20127 return qe_invalid;
20128 }
20129
20130 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20131
20132
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20133 {
20134 return qe_invalid;
20135 }
20136
20137 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20138
20139
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20140 {
20141 return qe_invalid;
20142 }
20143
20144 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20145
20146
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20147 {
20148 return qe_invalid;
20149 }
20150
20151
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20152 {
20153
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20154 {
20155
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20156 {
20157 return qe_invalid;
20158 }
20159 32 }
20160 1 }
20161 60 }
20162 64 }
20163
20164 //old only
20165
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20166 {
20167 byte equipment, tmpitm; //bit flags
20168
20169
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20170 {
20171 return qe_invalid;
20172 }
20173
20174 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20175 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20176 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20177 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20178 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20179 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20180
20181
20182
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20183 {
20184 return qe_invalid;
20185 }
20186
20187 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20188 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20189 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20190 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20191 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20192 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20193 4 }
20194
20195
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20196 return qe_invalid;
20197 281 temp_zinit.mcounter[crLIFE] = tempbyte;
20198
20199
20200
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20201 {
20202 byte temphp;
20203
20204
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20205 {
20206 return qe_invalid;
20207 }
20208
20209 64 temp_zinit.counter[crLIFE]=temphp;
20210
20211
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20212 {
20213 return qe_invalid;
20214 }
20215
20216 64 temp_zinit.cont_heart=temphp;
20217 64 }
20218 else
20219 {
20220
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20221 {
20222 return qe_invalid;
20223 }
20224
20225
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.cont_heart,f))
20226 {
20227 return qe_invalid;
20228 }
20229 }
20230
20231
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.hcp,f))
20232 {
20233 return qe_invalid;
20234 }
20235
20236
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version >= 14)
20237 {
20238
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20239 {
20240 return qe_invalid;
20241 }
20242
20243
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(s_version<16) // July 2007
20244 {
20245 if(get_qr(qr_BRANGPICKUP+1))
20246 temp_zinit.hcp_per_hc = 0xFF;
20247
20248 //Dispose of legacy rule
20249 set_qr(qr_BRANGPICKUP+1, 0);
20250 }
20251 217 }
20252
20253
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20254 {
20255
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20256 return qe_invalid;
20257 264 temp_zinit.mcounter[crBOMBS] = padding;
20258 264 }
20259
20260
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20261 {
20262 return qe_invalid;
20263 }
20264
20265
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20266 {
20267 return qe_invalid;
20268 }
20269
20270
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20271 return qe_invalid;
20272
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 281 times.
2529 for(int q = 0; q < 8; ++q)
20273
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1744 times.
2248 SETFLAG(temp_zinit.litems[q+1], (1 << li_mcguffin), get_bitl(tempbyte, q));
20274
20275 281 int level_count = 32;
20276
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20277 217 level_count = 64;
20278 byte tmp_map[64];
20279 byte tmp_compass[64];
20280
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20281
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_map[i],f))
20282 return qe_invalid;
20283
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20284
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_compass[i],f))
20285 return qe_invalid;
20286
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 281 times.
127769 for(int q = 0; q < level_count*8; ++q)
20287 {
20288
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 126692 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
20289
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 127479 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
20290 127488 }
20291
20292
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20293 //new only
20294
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20295 {
20296 byte tmp_boss_key[64];
20297
2/2
✓ Branch 0 taken 15808 times.
✓ Branch 1 taken 277 times.
16085 for(int32_t i=0; i<level_count; i++)
20298 {
20299
1/2
✓ Branch 0 taken 15808 times.
✗ Branch 1 not taken.
15808 if(!p_getc(&tmp_boss_key[i],f))
20300 {
20301 return qe_invalid;
20302 }
20303 15808 }
20304
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 277 times.
126741 for(int q = 0; q < level_count*8; ++q)
20305 {
20306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126464 times.
126464 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20307 126464 }
20308 277 }
20309
20310 byte tmpmisc[16];
20311
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 281 times.
4777 for(int32_t i=0; i<16; i++)
20312
1/2
✓ Branch 0 taken 4496 times.
✗ Branch 1 not taken.
4496 if(!p_getc(&tmpmisc[i],f))
20313 return qe_invalid;
20314 281 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20315 281 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20316 281 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20317
20318
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
537 if(s_version < 15) for(int32_t i=0; i<4; i++)
20319
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20320 64 return qe_invalid;
20321
20322
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_map,f))
20323 {
20324 return qe_invalid;
20325 }
20326
20327
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_screen,f))
20328 {
20329 return qe_invalid;
20330 }
20331
20332
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20333 {
20334 byte tempmp;
20335
20336
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20337 {
20338 return qe_invalid;
20339 }
20340
20341 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20342
20343
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20344 {
20345 return qe_invalid;
20346 }
20347
20348 64 temp_zinit.counter[crMAGIC]=tempmp;
20349 64 }
20350 else
20351 {
20352
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20353 {
20354 return qe_invalid;
20355 }
20356
20357
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20358 {
20359 return qe_invalid;
20360 }
20361 }
20362
20363
20364
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 15)
20365 {
20366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20367 {
20368 64 temp_zinit.mcounter[crMAGIC]*=32;
20369 64 temp_zinit.counter[crMAGIC]*=32;
20370 64 }
20371
20372
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20373 {
20374
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20375 {
20376 return qe_invalid;
20377 }
20378 256 }
20379
20380
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20381 {
20382 return qe_invalid;
20383 }
20384 64 }
20385 else
20386 {
20387
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.bomb_ratio,f))
20388 return qe_invalid;
20389
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(temp_zinit.bomb_ratio < 1)
20390 temp_zinit.bomb_ratio = 1;
20391 217 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20392 }
20393
20394
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 15)
20395 {
20396 byte tempbp;
20397
20398
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20399 {
20400
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20401 {
20402 return qe_invalid;
20403 }
20404
20405 256 beam_power[i]=tempbp;
20406 256 }
20407
20408
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20409 {
20410 return qe_invalid;
20411 }
20412
20413
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20414 {
20415 if(!p_getc(&hookshot_length,f))
20416 {
20417 return qe_invalid;
20418 }
20419
20420 if(!p_getc(&longshot_links,f))
20421 {
20422 return qe_invalid;
20423 }
20424
20425 if(!p_getc(&longshot_length,f))
20426 {
20427 return qe_invalid;
20428 }
20429 }
20430 64 }
20431
20432
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_x,f))
20433 {
20434 return qe_invalid;
20435 }
20436
20437
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_y,f))
20438 {
20439 return qe_invalid;
20440 }
20441
20442
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&subscr_mode,f))
20443 return qe_invalid;
20444
20445 //old only
20446
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20447 {
20448 byte tmp_boss_key[32];
20449
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20450 {
20451
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20452 {
20453 return qe_invalid;
20454 }
20455 128 }
20456
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20457 {
20458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20459 1024 }
20460 4 }
20461
20462
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
281 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20463 {
20464
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 217 times.
277 if(s_version <= 10)
20465 {
20466
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20467 {
20468 return qe_invalid;
20469 }
20470
20471 60 temp_zinit.start_dmap = (word)tempbyte;
20472 60 }
20473 else
20474 {
20475
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.start_dmap,f))
20476 {
20477 return qe_invalid;
20478 }
20479 }
20480
20481
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20482 {
20483 return qe_invalid;
20484 }
20485 277 }
20486
20487
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 200 times.
281 if(s_version>1 && s_version < 29)
20488 {
20489
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20490 return qe_invalid;
20491 200 temp_zinit.counter[crARROWS] = padding;
20492
20493
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20494 return qe_invalid;
20495 200 temp_zinit.mcounter[crARROWS] = padding;
20496 200 }
20497
20498
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>2)
20499 {
20500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(s_version <= 10)
20501 {
20502 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20503 {
20504 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20505 {
20506 return qe_invalid;
20507 }
20508 }
20509 }
20510 else
20511 {
20512
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 217 times.
111321 for(int32_t i=0; i<MAXLEVELS; i++)
20513 {
20514
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20515 {
20516 return qe_invalid;
20517 }
20518 111104 }
20519 }
20520 217 }
20521
20522
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>3)
20523 {
20524
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20525 {
20526 return qe_invalid;
20527 }
20528
20529
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20530 {
20531 return qe_invalid;
20532 }
20533
20534
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20535 {
20536 return qe_invalid;
20537 }
20538
20539
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20540 {
20541 return qe_invalid;
20542 }
20543
20544
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20545 {
20546 return qe_invalid;
20547 }
20548
20549
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20550 {
20551 return qe_invalid;
20552 }
20553
20554
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20555 {
20556 return qe_invalid;
20557 }
20558
20559
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_flags,f))
20560 {
20561 return qe_invalid;
20562 }
20563
20564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20566 217 }
20567
20568
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>4 && s_version<15)
20569 {
20570 if(!p_getc(&moving_fairy_hearts,f))
20571 {
20572 return qe_invalid;
20573 }
20574
20575 if(!p_getc(&moving_fairy_heart_percent,f))
20576 {
20577 return qe_invalid;
20578 }
20579 }
20580
20581
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>5 && s_version < 10)
20582 {
20583 if(!p_getc(&temp,f))
20584 {
20585 return qe_invalid;
20586 }
20587
20588 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20589 }
20590
20591
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>6 && s_version<15)
20592 {
20593 if(!p_getc(&stationary_fairy_hearts,f))
20594 {
20595 return qe_invalid;
20596 }
20597
20598 if(!p_getc(&stationary_fairy_heart_percent,f))
20599 {
20600 return qe_invalid;
20601 }
20602
20603 if(!p_getc(&moving_fairy_magic,f))
20604 {
20605 return qe_invalid;
20606 }
20607
20608 if(!p_getc(&moving_fairy_magic_percent,f))
20609 {
20610 return qe_invalid;
20611 }
20612
20613 if(!p_getc(&stationary_fairy_magic,f))
20614 {
20615 return qe_invalid;
20616 }
20617
20618 if(!p_getc(&stationary_fairy_magic_percent,f))
20619 {
20620 return qe_invalid;
20621 }
20622
20623 if(!p_getc(&blue_potion_hearts,f))
20624 {
20625 return qe_invalid;
20626 }
20627
20628 if(!p_getc(&blue_potion_heart_percent,f))
20629 {
20630 return qe_invalid;
20631 }
20632
20633 if(!p_getc(&red_potion_hearts,f))
20634 {
20635 return qe_invalid;
20636 }
20637
20638 if(!p_getc(&red_potion_heart_percent,f))
20639 {
20640 return qe_invalid;
20641 }
20642
20643 if(!p_getc(&blue_potion_magic,f))
20644 {
20645 return qe_invalid;
20646 }
20647
20648 if(!p_getc(&blue_potion_magic_percent,f))
20649 {
20650 return qe_invalid;
20651 }
20652
20653 if(!p_getc(&red_potion_magic,f))
20654 {
20655 return qe_invalid;
20656 }
20657
20658 if(!p_getc(&red_potion_magic_percent,f))
20659 {
20660 return qe_invalid;
20661 }
20662 }
20663
20664
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>6)
20665
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20666 return qe_invalid;
20667
20668
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>7)
20669 {
20670
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20671 {
20672 return qe_invalid;
20673 }
20674 217 }
20675
20676
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>8)
20677 {
20678
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20679 {
20680 return qe_invalid;
20681 }
20682
20683
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20684 {
20685 return qe_invalid;
20686 }
20687 217 }
20688
20689
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version>16)
20690 {
20691
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&tempbyte,f))
20692 {
20693 return qe_invalid;
20694 }
20695 217 temp_zinit.gravity = tempbyte*100;
20696
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.terminalv,f))
20697 {
20698 return qe_invalid;
20699 }
20700
20701
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_speed,f))
20702 {
20703 return qe_invalid;
20704 }
20705
20706
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20707 {
20708 return qe_invalid;
20709 }
20710
20711
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20712 {
20713 return qe_invalid;
20714 }
20715 217 }
20716
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20717 12 temp_zinit.msg_speed = 0;
20718
20719
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>17)
20720 {
20721
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20722 {
20723 return qe_invalid;
20724 }
20725 217 }
20726
20727 //expaned init data for larger values in 2.55
20728
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 17 times.
281 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20729 {
20730
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20731 {
20732 return qe_invalid;
20733 }
20734
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20735 {
20736 return qe_invalid;
20737 }
20738
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20739 {
20740 return qe_invalid;
20741 }
20742
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20743 {
20744 return qe_invalid;
20745 }
20746
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20747 {
20748 return qe_invalid;
20749 }
20750
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20751 {
20752 return qe_invalid;
20753 }
20754
20755 17 }
20756
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 20 )
20757 {
20758
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20759 {
20760 return qe_invalid;
20761 }
20762 17 }
20763 else
20764 {
20765 264 temp_zinit.heroStep = 150; //1.5 pixels per frame
20766 }
20767
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 21 )
20768 {
20769
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20770 {
20771 return qe_invalid;
20772 }
20773 17 }
20774 else
20775 {
20776 264 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20777 }
20778 //old only
20779
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20780 {
20781 byte items2;
20782
20783
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20784 {
20785 return qe_invalid;
20786 }
20787
20788 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20789 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20790 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20791 4 }
20792
20793
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5 times.
281 if(Header->zelda_version < 0x193)
20794 {
20795
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20796 {
20797
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20798 {
20799 return qe_invalid;
20800 }
20801 480 }
20802
20803 //new only
20804
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20805 {
20806
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20807 {
20808 return qe_invalid;
20809 }
20810
20811
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20812 {
20813 return qe_invalid;
20814 }
20815 1 }
20816 5 }
20817 281 }
20818
20819
3/6
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20820 {
20821 //temp_zinit.shield=i_smallshield;
20822 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20823
20824
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20825 82 temp_zinit.set_item(sshieldid, true);
20826 82 }
20827
20828
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20829 {
20830 18 temp_zinit.mcounter[crLIFE]=3;
20831 18 temp_zinit.counter[crLIFE]=3;
20832 18 temp_zinit.cont_heart=3;
20833 18 temp_zinit.mcounter[crBOMBS]=8;
20834 18 }
20835
20836
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20837 {
20838 18 sword_hearts[0]=0;
20839 18 sword_hearts[1]=5;
20840 18 sword_hearts[2]=12;
20841 18 sword_hearts[3]=21;
20842 18 }
20843
20844
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20845 {
20846 18 temp_zinit.last_map=0;
20847 18 temp_zinit.last_screen=0;
20848 18 }
20849
20850
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20851 {
20852 18 temp_zinit.mcounter[crMAGIC]=0;
20853 18 temp_zinit.counter[crMAGIC]=0;
20854 18 temp_zinit.magicdrainrate = 2;
20855 18 }
20856
20857
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20858 {
20859
20860
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20861 {
20862 72 beam_hearts[x]=100;
20863 72 }
20864
20865
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20866 {
20867 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20868 72 set_qr(qr_LENSHINTS+i,0);
20869 72 }
20870
20871
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20872 {
20873 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20874 72 }
20875
20876 18 set_qr(qr_HIDECARRIEDITEMS,0);
20877 18 hookshot_links=100;
20878 18 temp_zinit.msg_more_x=224;
20879 18 temp_zinit.msg_more_y=64;
20880 18 }
20881
20882 // Okay, let's put these legacy values into itemsbuf.
20883
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 15)
20884
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20885 {
20886
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20887 {
20888 case iFairyStill:
20889 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20890 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20891 82 itemsbuf[i].misc3 = 0;
20892
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20893
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20894 82 break;
20895
20896 case iFairyMoving:
20897 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20898 82 itemsbuf[i].misc2 = moving_fairy_magic;
20899 82 itemsbuf[i].misc3 = 50;
20900
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20901
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20902 82 break;
20903
20904 case iRPotion:
20905 82 itemsbuf[i].misc1 = red_potion_hearts;
20906 82 itemsbuf[i].misc2 = red_potion_magic;
20907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20909 82 break;
20910
20911 case iBPotion:
20912 82 itemsbuf[i].misc1 = blue_potion_hearts;
20913 82 itemsbuf[i].misc2 = blue_potion_magic;
20914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20916 82 break;
20917
20918 case iSword:
20919 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20920 82 itemsbuf[i].misc1 = beam_hearts[0];
20921 82 itemsbuf[i].misc2 = beam_power[0];
20922 // It seems that item_flag1 was already added by reset_itembuf()...
20923 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20924 82 break;
20925
20926 case iWSword:
20927 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20928 82 itemsbuf[i].misc1 = beam_hearts[1];
20929 82 itemsbuf[i].misc2 = beam_power[1];
20930 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20931 82 break;
20932
20933 case iMSword:
20934 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20935 82 itemsbuf[i].misc1 = beam_hearts[2];
20936 82 itemsbuf[i].misc2 = beam_power[2];
20937 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20938 82 break;
20939
20940 case iXSword:
20941 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20942 82 itemsbuf[i].misc1 = beam_hearts[3];
20943 82 itemsbuf[i].misc2 = beam_power[3];
20944 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20945 82 break;
20946
20947 case iHookshot:
20948 82 itemsbuf[i].misc1 = hookshot_length;
20949 82 itemsbuf[i].misc2 = hookshot_links;
20950 82 break;
20951
20952 case iLongshot:
20953 82 itemsbuf[i].misc1 = longshot_length;
20954 82 itemsbuf[i].misc2 = longshot_links;
20955 82 break;
20956 }
20957 21074 }
20958
20959
6/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20960 {
20961 //was new subscreen rule
20962 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20963 22 set_qr(qr_FREEFORM,0);
20964 22 }
20965
20966
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20967 {
20968 23 temp_zinit.start_dmap=0;
20969 23 }
20970
20971
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20972 {
20973 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20974 23 }
20975
20976
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
299 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20977 {
20978 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20979 temp_zinit.mcounter[crMONEY]=999;
20980 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20981 }
20982
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20983 {
20984 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20985 6 temp_zinit.mcounter[crBOMBS] = 8;
20986 6 }
20987 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20988 //time to ensure that we port all new values properly:
20989
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(Header->zelda_version < 0x250)
20990 {
20991
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20992 82 }
20993
20994
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 21)
20995 {
20996
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
20997 {
20998 return qe_invalid;
20999 }
21000
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
21001 {
21002 return qe_invalid;
21003 }
21004
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21005 {
21006 return qe_invalid;
21007 }
21008
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21009 {
21010 return qe_invalid;
21011 }
21012 17 }
21013 else
21014 {
21015 282 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
21016 282 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
21017 282 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
21018 282 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
21019 }
21020
21021
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 22)
21022 {
21023
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
21025 return qe_invalid;
21026
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
21028 return qe_invalid;
21029 17 }
21030
21031
21032
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 23)
21033 {
21034
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
21035 {
21036 return qe_invalid;
21037 }
21038
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
21039 {
21040 return qe_invalid;
21041 }
21042
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
21043 {
21044 return qe_invalid;
21045 }
21046
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
21047 {
21048 return qe_invalid;
21049 }
21050
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
21051 {
21052 return qe_invalid;
21053 }
21054 17 }
21055 else
21056 {
21057 282 temp_zinit.dither_type = 0;
21058 282 temp_zinit.dither_arg = 0;
21059 282 temp_zinit.dither_percent = 20;
21060 282 temp_zinit.def_lightrad = 24;
21061 282 temp_zinit.transdark_percent = 0;
21062 }
21063
21064
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 24)
21065 {
21066
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
21067 {
21068 return qe_invalid;
21069 }
21070 17 }
21071 else
21072 {
21073 282 temp_zinit.darkcol = BLACK;
21074 }
21075
21076
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 25)
21077 {
21078
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
21079 {
21080 return qe_invalid;
21081 }
21082
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
21083 {
21084 return qe_invalid;
21085 }
21086 17 }
21087
21088
21089
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 26)
21090 {
21091
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21092 {
21093 return qe_invalid;
21094 }
21095
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21096 {
21097 return qe_invalid;
21098 }
21099
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21100 {
21101 return qe_invalid;
21102 }
21103 17 }
21104 else
21105 {
21106 282 temp_zinit.heroSideswimUpStep = 150;
21107 282 temp_zinit.heroSideswimSideStep = 100;
21108 282 temp_zinit.heroSideswimDownStep = 75;
21109 }
21110
21111
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 27)
21112 {
21113
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21114 {
21115 return qe_invalid;
21116 }
21117 17 }
21118 else
21119 {
21120 282 temp_zinit.exitWaterJump = 0;
21121 }
21122
21123
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 29)
21124 {
21125
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21126 {
21127 return qe_invalid;
21128 }
21129 17 }
21130 else
21131 {
21132 282 temp_zinit.bunny_ltm = 0;
21133 }
21134
21135
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 30)
21136 {
21137
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
21138 {
21139 return qe_invalid;
21140 }
21141 17 }
21142 else
21143 {
21144 282 temp_zinit.switchhookstyle = 1;
21145 }
21146
21147
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 31)
21148 {
21149
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21150 {
21151 return qe_invalid;
21152 }
21153 17 }
21154
21155 299 temp_zinit.clear_genscript();
21156
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 12 times.
299 if(s_version > 32)
21157 {
21158 12 word numgenscript = 0;
21159
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21160 return qe_invalid;
21161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21162 return qe_invalid;
21163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21164 {
21165 if(!p_getc(&tempbyte,f))
21166 return qe_invalid;
21167 if(!(tempbyte&2))
21168 continue;
21169 temp_zinit.gen_doscript.set(q, tempbyte&1);
21170 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21171 return qe_invalid;
21172 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21173 return qe_invalid;
21174 for(auto p = 0; p < 8; ++p)
21175 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21176 return qe_invalid;
21177 dword sz;
21178 if(!p_igetl(&sz,f))
21179 return qe_invalid;
21180 temp_zinit.gen_data[q].resize(sz);
21181 std::vector<int32_t> dummy;
21182 if(!p_getlvec(&dummy,f))
21183 return qe_invalid;
21184 temp_zinit.gen_data[q] = dummy;
21185 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21186 return qe_invalid;
21187 }
21188 12 }
21189
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(s_version > 33)
21190 {
21191
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21192 return qe_invalid;
21193
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21194 return qe_invalid;
21195 6 }
21196
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(s_version > 34)
21197 {
21198 uint32_t num_used_mapscr_data;
21199 if(!p_igetl(&num_used_mapscr_data,f))
21200 return qe_invalid;
21201 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21202 {
21203 uint32_t sz;
21204 if(!p_igetl(&sz,f))
21205 return qe_invalid;
21206 temp_zinit.screen_data[q].resize(sz);
21207 if(sz)
21208 {
21209 std::vector<int32_t> dummy;
21210 if(!p_getlvec(&dummy,f))
21211 return qe_invalid;
21212 temp_zinit.screen_data[q] = dummy;
21213 }
21214 }
21215 }
21216
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if (s_version > 35)
21217 if(!p_igetzf(&temp_zinit.shove_offset,f))
21218 return qe_invalid;
21219
21220 299 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21221 299 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21222
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 110 times.
299 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21223 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21224
21225 299 return 0;
21226 299 }
21227 480 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21228 {
21229 480 zinitdata temp_zinit = {};
21230
21231
3/4
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
480 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21232
21233 int32_t dummy;
21234 480 word s_version=0;
21235 byte padding;
21236
21237
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 23 times.
480 if(Header->zelda_version > 0x192)
21238 {
21239
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetw(&s_version,f))
21240 return qe_invalid;
21241
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if (s_version > V_INITDATA)
21242 return qe_version;
21243 457 FFCore.quest_format[vInitData] = s_version;
21244
21245
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!read_deprecated_section_cversion(f))
21246 return qe_invalid;
21247
21248 //section size
21249
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!p_igetl(&dummy,f))
21250 return qe_invalid;
21251 457 }
21252
21253
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 181 times.
480 if(s_version < 37)
21254 {
21255
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21256 return ret;
21257 299 }
21258 else
21259 {
21260 181 subscr_mode = ssdtMAX;
21261
2/2
✓ Branch 0 taken 5792 times.
✓ Branch 1 taken 181 times.
5973 for(int q = 0; q < MAXITEMS/8; ++q)
21262
2/4
✓ Branch 0 taken 5792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5792 times.
5792 if(!p_getc(&temp_zinit.items[q], f))
21263 return qe_invalid;
21264
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 46 times.
181 if(s_version >= 42)
21265 {
21266
2/2
✓ Branch 0 taken 69120 times.
✓ Branch 1 taken 135 times.
69255 for(int q = 0; q < MAXLEVELS; ++q)
21267 {
21268
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 65536 times.
69120 if (s_version >= 44)
21269 {
21270
2/4
✓ Branch 0 taken 65536 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 65536 times.
65536 if(!p_igetw(&temp_zinit.litems[q], f))
21271 return qe_invalid;
21272 65536 }
21273 else
21274 {
21275
2/4
✓ Branch 0 taken 3584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3584 times.
3584 if(!p_getc(&padding, f))
21276 return qe_invalid;
21277 3584 temp_zinit.litems[q] = word(padding);
21278 }
21279 69120 }
21280 135 }
21281 else
21282 {
21283 byte tmp_map[MAXLEVELS/8];
21284 byte tmp_compass[MAXLEVELS/8];
21285 byte tmp_boss_key[MAXLEVELS/8];
21286 byte tmp_mcguffin[MAXLEVELS/8];
21287
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 46 times.
2990 for(int q = 0; q < MAXLEVELS/8; ++q)
21288 {
21289
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_map[q], f))
21290 return qe_invalid;
21291
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_compass[q], f))
21292 return qe_invalid;
21293
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2944 times.
2944 if(!p_getc(&tmp_boss_key[q], f))
21294 return qe_invalid;
21295
2/4
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944 times.
✗ Branch 3 not taken.
2944 if(!p_getc(&tmp_mcguffin[q], f))
21296 return qe_invalid;
21297 2944 }
21298
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 46 times.
23598 for(int q = 0; q < MAXLEVELS; ++q)
21299 {
21300
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23552 times.
✗ Branch 3 not taken.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
21301
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 23532 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
21302
2/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23552 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
21303
3/4
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23408 times.
✓ Branch 3 taken 144 times.
23552 SETFLAG(temp_zinit.litems[q], (1 << li_mcguffin), get_bit(tmp_mcguffin, q));
21304 23552 }
21305 }
21306
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbvec(&temp_zinit.level_keys, f))
21307 return qe_invalid;
21308 byte num_counters;
21309
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&num_counters,f))
21310 return qe_invalid;
21311
2/2
✓ Branch 0 taken 19367 times.
✓ Branch 1 taken 181 times.
19548 for(int q = 0; q < num_counters; ++q)
21312
2/4
✓ Branch 0 taken 19367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19367 times.
19367 if(!p_igetw(&temp_zinit.counter[q],f))
21313 return qe_invalid;
21314
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 19367 times.
19548 for(int q = 0; q < num_counters; ++q)
21315
2/4
✓ Branch 0 taken 19367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19367 times.
19367 if(!p_igetw(&temp_zinit.mcounter[q],f))
21316 return qe_invalid;
21317
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.bomb_ratio,f))
21318 return qe_invalid;
21319
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hcp,f))
21320 return qe_invalid;
21321
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21322 return qe_invalid;
21323
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_igetw(&temp_zinit.cont_heart,f))
21324 return qe_invalid;
21325
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hp_per_heart,f))
21326 return qe_invalid;
21327
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_getc(&temp_zinit.magic_per_block,f))
21328 return qe_invalid;
21329
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21330 return qe_invalid;
21331
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21332 return qe_invalid;
21333
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.dither_type,f))
21334 return qe_invalid;
21335
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.dither_arg,f))
21336 return qe_invalid;
21337
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_getc(&temp_zinit.dither_percent,f))
21338 return qe_invalid;
21339
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.def_lightrad,f))
21340 return qe_invalid;
21341
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.transdark_percent,f))
21342 return qe_invalid;
21343
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.darkcol,f))
21344 return qe_invalid;
21345
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21346 return qe_invalid;
21347
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21348 return qe_invalid;
21349
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21350 return qe_invalid;
21351
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21352 return qe_invalid;
21353
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21354 return qe_invalid;
21355
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21356 return qe_invalid;
21357
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21358 return qe_invalid;
21359
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.ss_flags,f))
21360 return qe_invalid;
21361
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbitstr(&temp_zinit.flags,f))
21362 return qe_invalid;
21363
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_getc(&temp_zinit.last_map,f))
21364 return qe_invalid;
21365
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.last_screen,f))
21366 return qe_invalid;
21367
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_more_x,f))
21368 return qe_invalid;
21369
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_more_y,f))
21370 return qe_invalid;
21371
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21372 return qe_invalid;
21373
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.msg_speed,f))
21374 return qe_invalid;
21375
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.gravity,f))
21376 return qe_invalid;
21377
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.swimgravity,f))
21378 return qe_invalid;
21379
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.terminalv,f))
21380 return qe_invalid;
21381
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21382 return qe_invalid;
21383
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21384 return qe_invalid;
21385
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.hero_swim_div,f))
21386 return qe_invalid;
21387
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21388 return qe_invalid;
21389
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21390 return qe_invalid;
21391
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21392 return qe_invalid;
21393
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21394 return qe_invalid;
21395
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.heroStep,f))
21396 return qe_invalid;
21397
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21398 return qe_invalid;
21399
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21400 return qe_invalid;
21401
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21402 return qe_invalid;
21403
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.start_dmap,f))
21404 return qe_invalid;
21405
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21406 return qe_invalid;
21407
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.switchhookstyle,f))
21408 return qe_invalid;
21409
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getc(&temp_zinit.magicdrainrate,f))
21410 return qe_invalid;
21411
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_igetzf(&temp_zinit.shove_offset,f))
21412 return qe_invalid;
21413
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21414 return qe_invalid;
21415
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21416 return qe_invalid;
21417
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21418 return qe_invalid;
21419
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
181 if(!p_getbmap(&temp_zinit.gen_initd, f))
21420 return qe_invalid;
21421
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21422 return qe_invalid;
21423
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.gen_data, f))
21424 return qe_invalid;
21425
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if(!p_getbmap(&temp_zinit.screen_data, f))
21426 return qe_invalid;
21427
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if (s_version >= 38)
21428 {
21429
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21430 return qe_invalid;
21431
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21432 return qe_invalid;
21433
2/4
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
181 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21434 return qe_invalid;
21435 181 }
21436
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
181 if(s_version >= 39)
21437
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_igetzf(&temp_zinit.air_drag, f))
21438 return qe_invalid;
21439
21440 // TODO: this first branch can likely be removed, as it only fixes an issues
21441 // that existed for a handful of temporary z3 builds (and active users of that
21442 // fork would have been updating often, beyond s_version 40).
21443
3/4
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153 times.
181 if (Header->is_z3 && s_version == 40)
21444 {
21445 if(!p_getc(&temp_zinit.region_mapping, f))
21446 return qe_invalid;
21447 }
21448 else
21449 {
21450
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
181 if(s_version >= 40)
21451 {
21452
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21453 return qe_invalid;
21454
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_igetw(&temp_zinit.light_wave_size, f))
21455 return qe_invalid;
21456 153 }
21457
21458
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 28 times.
181 if(s_version >= 41)
21459 {
21460
2/4
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
153 if(!p_getc(&temp_zinit.region_mapping, f))
21461 return qe_invalid;
21462 153 }
21463 }
21464
21465
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 129 times.
181 if(s_version >= 43)
21466
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21467
2/4
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33024 times.
✗ Branch 3 not taken.
33024 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21468 129 return qe_invalid;
21469
21470
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 53 times.
181 if(s_version >= 44)
21471
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 if (!p_getbvec(&temp_zinit.lvlswitches, f))
21472 return qe_invalid;
21473
21474
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 53 times.
181 if (s_version >= 45)
21475 {
21476
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 if (!p_igetw(&temp_zinit.item_spawn_flicker, f))
21477 return qe_invalid;
21478
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 if (!p_igetw(&temp_zinit.item_timeout_dur, f))
21479 return qe_invalid;
21480
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 if (!p_igetw(&temp_zinit.item_timeout_flicker, f))
21481 return qe_invalid;
21482
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 if (!p_getc(&temp_zinit.item_flicker_speed, f))
21483 return qe_invalid;
21484 128 }
21485
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 128 times.
181 if(s_version >= 46)
21486 {
21487
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 128 times.
768 for(int q = 0; q < SPRITE_THRESHOLD_MAX; ++q)
21488
2/4
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 640 times.
✗ Branch 3 not taken.
640 if(!p_igetw(&temp_zinit.sprite_z_thresholds[q], f))
21489 return qe_invalid;
21490 128 }
21491 }
21492
21493
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 352 times.
480 if(s_version < 46)
21494 {
21495 352 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_GROUND] = temp_zinit.jump_hero_layer_threshold;
21496 352 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_3] = temp_zinit.jump_hero_layer_threshold;
21497 352 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_4] = temp_zinit.jump_hero_layer_threshold;
21498 352 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_OVERHEAD] = word(-1);
21499 352 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_5] = word(-1);
21500 352 }
21501
21502
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if (should_skip)
21503 return 0;
21504
21505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(loading_tileset_flags & TILESET_CLEARMAPS)
21506 {
21507 temp_zinit.last_map = 0;
21508 temp_zinit.last_screen = 0;
21509 temp_zinit.screen_data.clear();
21510 }
21511
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 temp_zinit.normalize();
21512
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 zinit = temp_zinit;
21513
21514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 480 times.
480 if(zinit.heroAnimationStyle==las_zelda3slow)
21515 {
21516 hero_animation_speed=2;
21517 }
21518 else
21519 {
21520 480 hero_animation_speed=1;
21521 }
21522
21523 480 return 0;
21524 480 }
21525
21526 /*
21527 void setupitemdropsets()
21528 {
21529 for(int32_t i=0; i<isMAX; i++)
21530 {
21531 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21532 }
21533 }
21534 */
21535
21536 421 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21537 {
21538
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 23 times.
421 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21539
21540 dword dummy_dword;
21541 421 word item_drop_sets_to_read=0;
21542 item_drop_object tempitemdrop;
21543 421 word s_version=0;
21544
21545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
421 if (!should_skip)
21546
2/2
✓ Branch 0 taken 107776 times.
✓ Branch 1 taken 421 times.
108197 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21547 {
21548 107776 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21549 108197 }
21550
21551
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 23 times.
421 if(version > 0x192)
21552 {
21553 398 item_drop_sets_to_read=0;
21554
21555 //section version info
21556
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&s_version,f))
21557 {
21558 return qe_invalid;
21559 }
21560
21561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_ITEMDROPSETS)
21562 return qe_version;
21563
21564 398 FFCore.quest_format[vItemDropsets] = s_version;
21565
21566
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
21567 {
21568 return qe_invalid;
21569 }
21570
21571 //section size
21572
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy_dword,f))
21573 {
21574 return qe_invalid;
21575 }
21576
21577 //finally... section data
21578
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&item_drop_sets_to_read,f))
21579 {
21580 return qe_invalid;
21581 }
21582
21583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21584 {
21585 return qe_invalid;
21586 }
21587 398 }
21588 else
21589 {
21590 23 init_item_drop_sets();
21591 }
21592
21593
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 398 times.
421 if(s_version>=1)
21594 {
21595
2/2
✓ Branch 0 taken 6016 times.
✓ Branch 1 taken 398 times.
6414 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21596 {
21597
1/2
✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
6016 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21598 {
21599 return qe_invalid;
21600 }
21601
21602
2/2
✓ Branch 0 taken 60160 times.
✓ Branch 1 taken 6016 times.
66176 for(int32_t j=0; j<10; ++j)
21603 {
21604
1/2
✓ Branch 0 taken 60160 times.
✗ Branch 1 not taken.
60160 if(!p_igetw(&tempitemdrop.item[j],f))
21605 {
21606 return qe_invalid;
21607 }
21608 60160 }
21609
21610
2/2
✓ Branch 0 taken 66176 times.
✓ Branch 1 taken 6016 times.
72192 for(int32_t j=0; j<11; ++j)
21611 {
21612
1/2
✓ Branch 0 taken 66176 times.
✗ Branch 1 not taken.
66176 if(!p_igetw(&tempitemdrop.chance[j],f))
21613 {
21614 return qe_invalid;
21615 }
21616 66176 }
21617
21618 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21619 // overrides the quest's set #12.
21620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6016 if(s_version<2 && i==12)
21621 continue;
21622
21623 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21624
1/4
✓ Branch 0 taken 6016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6016 if(s_version<2) for(int32_t j=0; j<10; ++j)
21625 {
21626 int32_t it = tempitemdrop.item[j];
21627
21628 if((itemsbuf[it].type == itype_rupee
21629 && ((itemsbuf[it].amount)&0xFFF) == 10)
21630 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21631 {
21632 tempitemdrop.chance[j+1]=0;
21633 }
21634 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21635 {
21636 tempitemdrop.chance[j+1]=0;
21637 }
21638
21639 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21640 if(itemsbuf[it].type == itype_misc)
21641 {
21642 // If a non-gameplay item was selected, then item drop was aborted.
21643 // Reflect this by increasing the 'Nothing' chance accordingly.
21644 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21645 tempitemdrop.chance[j+1]=0;
21646 }
21647 }
21648
21649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6016 times.
6016 if (!should_skip)
21650 6016 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21651 6016 }
21652 398 }
21653
21654 421 return 0;
21655 421 }
21656
21657 398 int32_t readfavorites(PACKFILE *f, int32_t)
21658 {
21659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21660
21661 int32_t temp_num;
21662 dword dummy_dword;
21663 word num_favorite_combos;
21664 word num_favorite_combo_aliases;
21665 398 word s_version=0;
21666
21667 //section version info
21668
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&s_version,f))
21669 {
21670 return qe_invalid;
21671 }
21672
21673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (s_version > V_FAVORITES)
21674 return qe_version;
21675
21676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!should_skip)
21677 398 FFCore.quest_format[vFavourites] = s_version;
21678
21679
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!read_deprecated_section_cversion(f))
21680 {
21681 return qe_invalid;
21682 }
21683
21684 //section size
21685
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetl(&dummy_dword,f))
21686 {
21687 return qe_invalid;
21688 }
21689
21690 398 word per_row = FAVORITECOMBO_PER_ROW;
21691 398 word per_page = FAVORITECOMBO_PER_PAGE;
21692
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
398 if(s_version >= 3)
21693
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&per_row,f))
21694 return qe_invalid;
21695
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 181 times.
398 if(s_version >= 4)
21696
1/2
✓ Branch 0 taken 181 times.
✗ Branch 1 not taken.
181 if(!p_igetw(&per_page,f))
21697 return qe_invalid;
21698 //finally... section data
21699
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 if(!p_igetw(&num_favorite_combos,f))
21700 {
21701 return qe_invalid;
21702 }
21703
21704 //Hack; port old favorite combos
21705
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
398 if(s_version < 3 && num_favorite_combos == 100)
21706 211 per_row = 13;
21707
21708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!should_skip)
21709
2/2
✓ Branch 0 taken 501480 times.
✓ Branch 1 taken 398 times.
501878 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21710 501878 favorite_combos[q] = -1;
21711 398 byte favtype = 0;
21712
2/2
✓ Branch 0 taken 27995 times.
✓ Branch 1 taken 398 times.
28393 for(int32_t i=0; i<num_favorite_combos; i++)
21713 {
21714
2/2
✓ Branch 0 taken 6889 times.
✓ Branch 1 taken 21106 times.
27995 if (s_version >= 4)
21715 {
21716
1/2
✓ Branch 0 taken 6889 times.
✗ Branch 1 not taken.
6889 if (!p_getc(&favtype, f))
21717 {
21718 return qe_invalid;
21719 }
21720 6889 }
21721 else
21722 21106 favtype = 0;
21723
1/2
✓ Branch 0 taken 27995 times.
✗ Branch 1 not taken.
27995 if(!p_igetl(&temp_num,f))
21724 {
21725 return qe_invalid;
21726 }
21727
21728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27995 times.
27995 if (should_skip)
21729 continue;
21730
21731
2/2
✓ Branch 0 taken 6889 times.
✓ Branch 1 taken 21106 times.
27995 if(per_row == FAVORITECOMBO_PER_ROW)
21732 {
21733 6889 favorite_combos[i] = temp_num;
21734 6889 favorite_combo_modes[i] = favtype;
21735 6889 }
21736 else
21737 {
21738 21106 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21739 21106 favorite_combos[new_i]=temp_num;
21740 21106 favorite_combo_modes[new_i] = favtype;
21741 }
21742 27995 }
21743
21744 // Discard the separate favorite aliases list from previous versions
21745
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 217 times.
398 if(s_version<4)
21746 {
21747
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (!p_igetw(&num_favorite_combo_aliases, f))
21748 {
21749 return qe_invalid;
21750 }
21751
21752
2/2
✓ Branch 0 taken 21100 times.
✓ Branch 1 taken 217 times.
21317 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21753 {
21754
1/2
✓ Branch 0 taken 21100 times.
✗ Branch 1 not taken.
21100 if (!p_igetl(&temp_num, f))
21755 {
21756 return qe_invalid;
21757 }
21758 21100 }
21759 217 }
21760
21761 398 word max_combo_cols = 0;
21762 398 word max_mappages = 0;
21763
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 187 times.
398 if(s_version >= 2)
21764 {
21765
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&max_combo_cols,f))
21766 return qe_invalid;
21767 187 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21768
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 187 times.
935 for(int q = 0; q < max_combo_cols; ++q)
21769 {
21770
1/2
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
748 if(!p_igetl(&tmp,f))
21771 return qe_invalid;
21772
1/2
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
748 if(!p_igetl(&tmp2,f))
21773 return qe_invalid;
21774
1/2
✓ Branch 0 taken 748 times.
✗ Branch 1 not taken.
748 if(!p_igetl(&tmp3,f))
21775 return qe_invalid;
21776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
748 if(q < MAX_COMBO_COLS)
21777 {
21778 748 First[q] = tmp;
21779 748 combo_alistpos[q] = tmp2;
21780 748 combo_pool_listpos[q] = tmp3;
21781 748 }
21782 748 }
21783
21784
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if(!p_igetw(&max_mappages,f))
21785 return qe_invalid;
21786
2/2
✓ Branch 0 taken 1683 times.
✓ Branch 1 taken 187 times.
1870 for(int q = 0; q < max_mappages; ++q)
21787 {
21788
1/2
✓ Branch 0 taken 1683 times.
✗ Branch 1 not taken.
1683 if(!p_igetl(&tmp,f))
21789 return qe_invalid;
21790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 if(!p_igetl(&tmp2,f))
21791 return qe_invalid;
21792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 if(q < MAX_MAPPAGE_BTNS)
21793 {
21794 1683 map_page[q].map = tmp;
21795 1683 map_page[q].screen = tmp2;
21796 1683 }
21797 1683 }
21798 187 }
21799
21800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (should_skip)
21801 return 0;
21802
21803
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 398 times.
1242 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21804 {
21805 844 First[q] = 0;
21806 844 combo_alistpos[q] = 0;
21807 844 combo_pool_listpos[q] = 0;
21808 844 }
21809
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 398 times.
2297 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21810 {
21811 1899 map_page[q].map = 0;
21812 1899 map_page[q].screen = 0;
21813 1899 }
21814
21815 398 return 0;
21816 398 }
21817
21818 /*
21819 switch (ret) {
21820 case 0:
21821 break;
21822
21823 case qe_invalid:
21824 goto invalid;
21825 break;
21826 default:
21827 pack_fclose(f);
21828 if(!oldquest)
21829 delete_file(tmpfilename);
21830 return ret;
21831 break;
21832 }
21833 */
21834
21835 const char *skip_text[skip_max]=
21836 {
21837 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21838 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21839 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21840 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21841 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21842 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21843 "skip_favorites"
21844 };
21845
21846
21847 void port250QuestRules(){
21848
21849 portCandleRules(); //Candle
21850 portBombRules();
21851
21852 }
21853
21854 void portCandleRules()
21855 {
21856 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21857 //itemdata itemsbuf;
21858 for ( int32_t q = 0; q < MAXITEMS; q++ )
21859 {
21860 if ( itemsbuf[q].type == itype_candle )
21861 {
21862 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21863 else itemsbuf[q].flags &= ~ item_flag2;
21864 }
21865 }
21866 }
21867
21868 void portBombRules()
21869 {
21870 bool hurtshero = get_qr(qr_OUCHBOMBS);
21871 //itemdata itemsbuf;
21872 for ( int32_t q = 0; q < MAXITEMS; q++ )
21873 {
21874 if ( itemsbuf[q].type == itype_bomb )
21875 {
21876 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21877 else itemsbuf[q].flags &= ~ item_flag2;
21878 }
21879 }
21880 }
21881
21882 18597 static int section_id_to_enum(int id)
21883 {
21884
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 804 times.
✓ Branch 3 taken 804 times.
✓ Branch 4 taken 804 times.
✓ Branch 5 taken 804 times.
✓ Branch 6 taken 721 times.
✓ Branch 7 taken 804 times.
✓ Branch 8 taken 804 times.
✓ Branch 9 taken 804 times.
✓ Branch 10 taken 804 times.
✓ Branch 11 taken 804 times.
✓ Branch 12 taken 804 times.
✓ Branch 13 taken 721 times.
✓ Branch 14 taken 721 times.
✓ Branch 15 taken 804 times.
✓ Branch 16 taken 804 times.
✓ Branch 17 taken 745 times.
✓ Branch 18 taken 721 times.
✓ Branch 19 taken 721 times.
✓ Branch 20 taken 721 times.
✓ Branch 21 taken 804 times.
✓ Branch 22 taken 804 times.
✓ Branch 23 taken 745 times.
✓ Branch 24 taken 721 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18597 switch (id)
21885 {
21886 case ID_HEADER: return skip_header;
21887 804 case ID_RULES: return skip_rules;
21888 804 case ID_STRINGS: return skip_strings;
21889 804 case ID_MISC: return skip_misc;
21890 804 case ID_TILES: return skip_tiles;
21891 804 case ID_COMBOS: return skip_combos;
21892 721 case ID_COMBOALIASES: return skip_comboaliases;
21893 804 case ID_CSETS: return skip_csets;
21894 804 case ID_MAPS: return skip_maps;
21895 804 case ID_DMAPS: return skip_dmaps;
21896 804 case ID_DOORS: return skip_doors;
21897 804 case ID_ITEMS: return skip_items;
21898 804 case ID_WEAPONS: return skip_weapons;
21899 721 case ID_COLORS: return skip_colors;
21900 721 case ID_ICONS: return skip_icons;
21901 804 case ID_INITDATA: return skip_initdata;
21902 804 case ID_GUYS: return skip_guys;
21903 745 case ID_HEROSPRITES: return skip_herosprites;
21904 721 case ID_SUBSCREEN: return skip_subscreens;
21905 721 case ID_FFSCRIPT: return skip_ffscript;
21906 721 case ID_SFX: return skip_sfx;
21907 804 case ID_MIDIS: return skip_midis;
21908 804 case ID_CHEATS: return skip_cheats;
21909 745 case ID_ITEMDROPSETS: return skip_itemdropsets;
21910 721 case ID_FAVORITES: return skip_favorites;
21911 case ID_ZINFO: return skip_zinfo;
21912 }
21913
21914 return -1;
21915 18597 }
21916
21917 18189 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21918 {
21919 18189 int section_enum = section_id_to_enum(section_id);
21920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18189 times.
18189 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21921
2/2
✓ Branch 0 taken 6783 times.
✓ Branch 1 taken 11406 times.
18189 if (skip)
21922 {
21923 word s_version;
21924
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!p_igetw(&s_version,f))
21925 {
21926 return qe_invalid;
21927 }
21928
21929
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!read_deprecated_section_cversion(f))
21930 {
21931 return qe_invalid;
21932 }
21933
21934
3/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
6783 if (section_id == ID_RULES && s_version > 16)
21935 {
21936 dword dummy;
21937 if (!p_igetl(&dummy,f))
21938 {
21939 return qe_invalid;
21940 }
21941 }
21942
21943
3/4
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
✓ Branch 2 taken 323 times.
✗ Branch 3 not taken.
6783 if (section_id == ID_FFSCRIPT && s_version >= 18)
21944 {
21945 word dummy;
21946 if (!p_igetw(&dummy,f))
21947 {
21948 return qe_invalid;
21949 }
21950 }
21951
21952 dword section_length;
21953
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (!p_igetl(&section_length,f))
21954 {
21955 return qe_invalid;
21956 }
21957
21958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6783 times.
6783 if (pack_fseek(f, section_length))
21959 {
21960 return qe_invalid;
21961 }
21962
21963
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 6460 times.
6783 if (!pack_feof(f))
21964 {
21965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6460 times.
6460 if (!p_mgetl(&section_id,f))
21966 {
21967 return qe_invalid;
21968 }
21969 6460 }
21970
21971 6783 return qe_cancel;
21972 }
21973
21974 11406 return qe_OK;
21975 18189 }
21976
21977 // TODO: this was copied from zc/zasm_utils.cpp
21978 282 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21979 {
21980 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21981
21982 282 std::vector<zasm_script*> scripts;
21983
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 scripts.reserve(zasm_scripts.size());
21984
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 301585 times.
301867 for (auto& script : zasm_scripts)
21985
2/2
✓ Branch 0 taken 293103 times.
✓ Branch 1 taken 8482 times.
301585 if (script->valid())
21986
1/2
✓ Branch 0 taken 8482 times.
✗ Branch 1 not taken.
8482 scripts.push_back(script.get());
21987
21988
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 282 times.
✗ Branch 3 not taken.
282 std::for_each(scripts.begin(), scripts.end(), fn);
21989 282 }
21990
21991 480 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21992 {
21993 // 2.55.9 or newer?
21994
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 326 times.
480 if (header.compareVer(2, 55, 9) >= 0)
21995 154 return false; // defer to whatever was set
21996
21997 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
21998
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 276 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 276 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 276 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 288 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
326 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
21999 38 return true;
22000
22001 // Quests prior to 2.55.9 with a scripted subscreen?
22002
2/2
✓ Branch 0 taken 145923 times.
✓ Branch 1 taken 285 times.
146208 for (int i = 0; i < MAXDMAPS; i++)
22003 {
22004 145923 int script = DMaps[i].active_sub_script;
22005
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 145920 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
145923 if (script && dmapscripts[script] && dmapscripts[script]->valid())
22006 3 return true;
22007 145920 }
22008
22009 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
22010
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 std::string title = header.title;
22011
3/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 282 times.
285 if (title == "Yuurand: Tales of the Labyrinth")
22012 3 return true;
22013
22014 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
22015 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
22016 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
22017 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
22018 282 bool found = false;
22019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
8764 _zasm_for_every_script([&](auto script){
22020
2/2
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 5449 times.
8482 if (found) return;
22021
22022
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 23840130 times.
23845549 for (const auto& instr : script->zasm)
22023 {
22024
4/4
✓ Branch 0 taken 20882211 times.
✓ Branch 1 taken 2957919 times.
✓ Branch 2 taken 358211 times.
✓ Branch 3 taken 20524000 times.
23840130 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
22025
22026 3316130 int value = instr.arg2;
22027
9/10
✓ Branch 0 taken 3316128 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3316125 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3316101 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3316101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3316100 times.
3316130 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
22028 {
22029 30 found = true;
22030 30 break;
22031 }
22032 }
22033 8482 });
22034
22035 282 return found;
22036 480 }
22037
22038 static int32_t prev_quest_format[versiontypesLAST];
22039 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
22040 static byte prev_extra_rules[EXTRARULES_SIZE];
22041 static byte prev_midi_flags[MIDIFLAGS_SIZE];
22042 static word prev_map_count;
22043
22044 // When skipping any section, we are loading a qst file just to poke at a couple things.
22045 // We should not mutate important globals in that case.
22046 // We should also restore these globals when loading a qst fails.
22047 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
22048 // (see load_imagebuf).
22049 804 static void store_prev_qstload_global_state()
22050 {
22051 804 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
22052 804 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
22053 804 memcpy(prev_midi_flags, midi_flags, MIDIFLAGS_SIZE);
22054 804 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
22055 804 prev_map_count = map_count;
22056 804 }
22057
22058 324 static void restore_prev_qstload_global_state()
22059 {
22060 324 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
22061 324 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
22062 324 unpack_qrs();
22063 324 memcpy(midi_flags, prev_midi_flags, MIDIFLAGS_SIZE);
22064 324 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
22065 324 map_count = prev_map_count;
22066 324 }
22067
22068 //Internal function for loadquest wrapper
22069 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
22070 804 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
22071 {
22072 804 DMapEditorLastMaptileUsed = 0;
22073 804 combosread=false;
22074 804 mapsread=false;
22075 804 fixffcs=false;
22076
22077 804 store_prev_qstload_global_state();
22078
22079 804 bool skipping_any = false;
22080
2/2
✓ Branch 0 taken 3216 times.
✓ Branch 1 taken 804 times.
4020 for (int i = 0; i < 4; i++)
22081 3216 skipping_any |= skip_flags[i] ? true : false;
22082
22083 804 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
22084
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
22085 {
22086 set_bit(skip_flags, skip_ffscript, 1);
22087 setZScriptVersion(V_FFSCRIPT);
22088 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
22089 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
22090 do_clear_scripts = true;
22091 }
22092
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(loading_tileset_flags & TILESET_CLEARMAPS)
22093 {
22094 set_bit(skip_flags, skip_maps, 1);
22095 }
22096
22097 char tmpfilename[L_tmpnam];
22098 804 temp_name(tmpfilename);
22099 804 bool catchup=false;
22100 byte tempbyte;
22101
22102 // oldquest flag is set when an unencrypted qst file is suspected.
22103 804 bool oldquest = false;
22104 804 int32_t open_error=0;
22105 804 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
22106
22107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if (!f)
22108 {
22109 ASSERT(open_error != 0);
22110 return open_error;
22111 }
22112
22113 804 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
22114 804 memset(extra_rules, 0, EXTRARULES_SIZE);
22115 804 unpack_qrs();
22116
22117
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if (!get_bit(skip_flags, skip_maps))
22118 480 Regions = {};
22119
22120
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if(do_clear_scripts)
22121 {
22122 480 zScript.clear();
22123 480 globalmap.clear();
22124 480 genericmap.clear();
22125 480 ffcmap.clear();
22126 480 itemmap.clear();
22127 480 npcmap.clear();
22128 480 ewpnmap.clear();
22129 480 lwpnmap.clear();
22130 480 playermap.clear();
22131 480 dmapmap.clear();
22132 480 screenmap.clear();
22133 480 itemspritemap.clear();
22134 480 comboscriptmap.clear();
22135 480 subscreenmap.clear();
22136
22137
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
22138 {
22139 245280 ffcmap[i].clear();
22140 245280 }
22141
22142 480 globalmap[0].slotname = "Slot 1:";
22143 480 globalmap[0].scriptname = "~Init";
22144 480 globalmap[0].update();
22145
22146
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 480 times.
3840 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
22147 {
22148 3360 globalmap[i].clear();
22149 3360 }
22150
22151
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
22152 {
22153 122400 itemmap[i].clear();
22154 122400 }
22155
22156 //new script types -- prevent carrying over to a quest that you load after reading them
22157 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
22158
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
22159 {
22160 122400 npcmap[i].clear();
22161 122400 }
22162
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22163 {
22164 122400 lwpnmap[i].clear();
22165 122400 }
22166
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22167 {
22168 122400 ewpnmap[i].clear();
22169 122400 }
22170
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 480 times.
2400 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
22171 {
22172 1920 playermap[i].clear();
22173 1920 }
22174
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
22175 {
22176 122400 dmapmap[i].clear();
22177 122400 }
22178
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
22179 {
22180 122400 screenmap[i].clear();
22181 122400 }
22182
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
22183 {
22184 122400 itemspritemap[i].clear();
22185 122400 }
22186
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
22187 {
22188 245280 comboscriptmap[i].clear();
22189 245280 }
22190
2/2
✓ Branch 0 taken 245280 times.
✓ Branch 1 taken 480 times.
245760 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22191 {
22192 245280 genericmap[i].clear();
22193 245280 }
22194
2/2
✓ Branch 0 taken 122400 times.
✓ Branch 1 taken 480 times.
122880 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22195 {
22196 122400 subscreenmap[i].clear();
22197 122400 }
22198
22199 480 reset_scripts();
22200 480 }
22201
22202 804 zquestheader tempheader{};
22203
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tempheader.filename = filename;
22204
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 zinfo tempzi;
22205
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 tempzi.clear();
22206 804 load_tmp_zi = &tempzi;
22207
22208 char zinfofilename[2048];
22209
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 replace_extension(zinfofilename, filename, "zinfo", 2047);
22210 804 int32_t ret=0;
22211
22212 //header
22213
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("Reading Header...");
22214
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 ret=readheader(f, &tempheader, printmetadata);
22215
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
804 checkstatus(ret);
22216
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("okay.");
22217
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_eol();
22218
22219
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 606 times.
804 if(read_zinfo)
22220 {
22221
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 box_out("Reading ZInfo - ");
22222
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
198 box_out(read_ext_zinfo ? "External..." : "Internal...");
22223
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 195 times.
198 if(read_ext_zinfo)
22224 {
22225
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22226
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22228
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22229 3 }
22230 else
22231 {
22232
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 ret=readzinfo(f, tempzi, tempheader);
22233
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
195 checkstatus(ret);
22234 }
22235
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 box_out("okay.");
22236
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 box_eol();
22237 198 }
22238
22239
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 24 times.
804 if(tempheader.zelda_version>=0x193)
22240 {
22241 dword section_id;
22242
22243 //section id
22244
2/4
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
780 if(!p_mgetl(&section_id,f))
22245 {
22246 goto invalid;
22247 }
22248
22249 780 std::set<dword> seen_sections;
22250
22251
3/4
✓ Branch 0 taken 18969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18189 times.
✓ Branch 3 taken 780 times.
18969 while(!pack_feof(f))
22252 {
22253
2/4
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18189 times.
✗ Branch 3 not taken.
18189 if (seen_sections.contains(section_id))
22254 goto invalid;
22255
1/2
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
18189 seen_sections.insert(section_id);
22256
22257
3/4
✓ Branch 0 taken 18189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11406 times.
✓ Branch 3 taken 6783 times.
18189 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22258 {
22259
1/2
✓ Branch 0 taken 6783 times.
✗ Branch 1 not taken.
6783 if (retval == qe_cancel)
22260 6783 continue;
22261 checkstatus(retval);
22262 }
22263
22264
24/25
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 457 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 780 times.
✓ Branch 4 taken 457 times.
✓ Branch 5 taken 398 times.
✓ Branch 6 taken 780 times.
✓ Branch 7 taken 457 times.
✓ Branch 8 taken 457 times.
✓ Branch 9 taken 457 times.
✓ Branch 10 taken 457 times.
✓ Branch 11 taken 457 times.
✓ Branch 12 taken 398 times.
✓ Branch 13 taken 398 times.
✓ Branch 14 taken 457 times.
✓ Branch 15 taken 457 times.
✓ Branch 16 taken 398 times.
✓ Branch 17 taken 398 times.
✓ Branch 18 taken 398 times.
✓ Branch 19 taken 398 times.
✓ Branch 20 taken 457 times.
✓ Branch 21 taken 457 times.
✓ Branch 22 taken 398 times.
✓ Branch 23 taken 398 times.
✗ Branch 24 not taken.
11406 switch(section_id)
22265 {
22266 case ID_RULES:
22267
22268 //rules
22269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22270 {
22271 box_out("found.");
22272 box_eol();
22273 catchup=false;
22274 }
22275
22276
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Rules...");
22277
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readrules(f, &tempheader);
22278
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22279
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22280
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22281 457 break;
22282
22283 case ID_STRINGS:
22284
22285 //strings
22286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22287 {
22288 box_out("found.");
22289 box_eol();
22290 catchup=false;
22291 }
22292
22293
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Strings...");
22294
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readstrings(f, &tempheader);
22295
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22296
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22297
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22298 457 break;
22299
22300 case ID_MISC:
22301
22302 //misc data
22303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22304 {
22305 box_out("found.");
22306 box_eol();
22307 catchup=false;
22308 }
22309
22310
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Misc. Data...");
22311
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readmisc(f, &tempheader, Misc);
22312
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22313
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22314
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22315 780 break;
22316
22317 case ID_TILES:
22318
22319 //tiles
22320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22321 {
22322 box_out("found.");
22323 box_eol();
22324 catchup=false;
22325 }
22326
22327
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Tiles...");
22328
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22329
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22330
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22331
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22332 780 break;
22333
22334 case ID_COMBOS:
22335
22336 //combos
22337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22338 {
22339 box_out("found.");
22340 box_eol();
22341 catchup=false;
22342 }
22343
22344
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Combos...");
22345
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22346 457 combosread=true;
22347
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22348
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22349
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22350 457 break;
22351
22352 case ID_COMBOALIASES:
22353
22354 //combo aliases
22355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22356 {
22357 box_out("found.");
22358 box_eol();
22359 catchup=false;
22360 }
22361
22362
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Combo Aliases...");
22363
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22364
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22365
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22366
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22367 398 break;
22368
22369 case ID_CSETS:
22370
22371 //color data
22372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(catchup)
22373 {
22374 box_out("found.");
22375 box_eol();
22376 catchup=false;
22377 }
22378
22379
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("Reading Color Data...");
22380
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22381
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
780 checkstatus(ret);
22382
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_out("okay.");
22383
1/2
✓ Branch 0 taken 780 times.
✗ Branch 1 not taken.
780 box_eol();
22384 780 break;
22385
22386 case ID_MAPS:
22387
22388 //maps
22389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22390 {
22391 box_out("found.");
22392 box_eol();
22393 catchup=false;
22394 }
22395
22396
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Maps...");
22397
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readmaps(f, &tempheader);
22398 457 mapsread=true;
22399
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22400
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22401
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22402 457 break;
22403
22404 case ID_DMAPS:
22405
22406 //dmaps
22407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22408 {
22409 box_out("found.");
22410 box_eol();
22411 catchup=false;
22412 }
22413
22414
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading DMaps...");
22415
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22416
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22417
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22418
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22419 457 break;
22420
22421 case ID_DOORS:
22422
22423 //door combo sets
22424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22425 {
22426 box_out("found.");
22427 box_eol();
22428 catchup=false;
22429 }
22430
22431
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Doors...");
22432
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readdoorcombosets(f, &tempheader);
22433
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22434
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22435
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22436 457 break;
22437
22438 case ID_ITEMS:
22439
22440 //items
22441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22442 {
22443 box_out("found.");
22444 box_eol();
22445 catchup=false;
22446 }
22447
22448
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Items...");
22449
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22450
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22451
22452
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22453
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22454 457 break;
22455
22456 case ID_WEAPONS:
22457
22458 //weapons
22459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22460 {
22461 box_out("found.");
22462 box_eol();
22463 catchup=false;
22464 }
22465
22466
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Weapons...");
22467
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readweapons(f, &tempheader);
22468
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22469
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22470
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22471 457 break;
22472
22473 case ID_COLORS:
22474
22475 //misc. colors
22476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22477 {
22478 box_out("found.");
22479 box_eol();
22480 catchup=false;
22481 }
22482
22483
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Misc. Colors...");
22484
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readmisccolors(f, &tempheader, Misc);
22485
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22486
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22487
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22488 398 break;
22489
22490 case ID_ICONS:
22491
22492 //game icons
22493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22494 {
22495 box_out("found.");
22496 box_eol();
22497 catchup=false;
22498 }
22499
22500
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Game Icons...");
22501
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readgameicons(f, &tempheader, Misc);
22502
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22503
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22504
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22505 398 break;
22506
22507 case ID_INITDATA:
22508
22509 //initialization data
22510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22511 {
22512 box_out("found.");
22513 box_eol();
22514 catchup=false;
22515 }
22516
22517
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Init. Data...");
22518
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readinitdata(f, &tempheader);
22519
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22520
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22521
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22522
22523
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!get_bit(skip_flags, skip_subscreens))
22524 {
22525
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 363 times.
457 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22526 {
22527
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22528
22529
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22530 {
22531 48128 int32_t type=DMaps[i].type&dmfTYPE;
22532
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22533 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22534 48128 }
22535 94 }
22536 457 }
22537
22538
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!get_bit(skip_flags, skip_sfx))
22539 {
22540 457 setupsfx();
22541 457 }
22542
22543
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 if(!get_bit(skip_flags, skip_itemdropsets))
22544 {
22545
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 init_item_drop_sets();
22546 457 }
22547
22548
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
457 if(!get_bit(skip_flags, skip_favorites))
22549 {
22550 457 init_favorites();
22551 457 }
22552
22553 457 break;
22554
22555 case ID_GUYS:
22556
22557 //guys
22558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22559 {
22560 box_out("found.");
22561 box_eol();
22562 catchup=false;
22563 }
22564
22565
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Custom Guy Data...");
22566
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readguys(f, &tempheader);
22567
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22568
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22569
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22570 457 break;
22571
22572 case ID_HEROSPRITES:
22573
22574 //hero sprites
22575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22576 {
22577 box_out("found.");
22578 box_eol();
22579 catchup=false;
22580 }
22581
22582
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Custom Hero Sprite Data...");
22583
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readherosprites(f, &tempheader);
22584
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22585
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22586
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22587 398 break;
22588
22589 case ID_SUBSCREEN:
22590
22591 //custom subscreens
22592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22593 {
22594 box_out("found.");
22595 box_eol();
22596 catchup=false;
22597 }
22598
22599
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Custom Subscreen Data...");
22600
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readsubscreens(f);
22601
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22602
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22603
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22604 398 break;
22605
22606 case ID_FFSCRIPT:
22607
22608 //Freeform combo scripts
22609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22610 {
22611 box_out("found.");
22612 box_eol();
22613 catchup=false;
22614 }
22615
22616
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading FF Script Data...");
22617
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readffscript(f, &tempheader);
22618
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22619
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22620
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22621 398 break;
22622
22623 case ID_SFX:
22624
22625 //SFX data
22626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22627 {
22628 box_out("found.");
22629 box_eol();
22630 catchup=false;
22631 }
22632
22633
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading SFX Data...");
22634
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readsfx(f, &tempheader);
22635
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22636
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22637
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22638 398 break;
22639
22640 case ID_MIDIS:
22641
22642 //midis
22643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22644 {
22645 box_out("found.");
22646 box_eol();
22647 catchup=false;
22648 }
22649
22650
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading MIDIs...");
22651
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readmidis(f, &tempheader, tunes);
22652
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22653
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22654
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22655 457 break;
22656
22657 case ID_CHEATS:
22658
22659 //cheat codes
22660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(catchup)
22661 {
22662 box_out("found.");
22663 box_eol();
22664 catchup=false;
22665 }
22666
22667
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("Reading Cheat Codes...");
22668
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 ret=readcheatcodes(f, &tempheader);
22669
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
457 checkstatus(ret);
22670
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_out("okay.");
22671
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 box_eol();
22672 457 break;
22673
22674 case ID_ITEMDROPSETS:
22675
22676 //item drop sets
22677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22678 {
22679 box_out("found.");
22680 box_eol();
22681 catchup=false;
22682 }
22683
22684
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Item Drop Sets...");
22685
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readitemdropsets(f, tempheader.zelda_version);
22686
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22687
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22688
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22689 398 break;
22690
22691 case ID_FAVORITES:
22692
22693 //favorite combos and combo aliases
22694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(catchup)
22695 {
22696 box_out("found.");
22697 box_eol();
22698 catchup=false;
22699 }
22700
22701
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("Reading Favorite Combos...");
22702
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 ret=readfavorites(f, tempheader.zelda_version);
22703
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
398 checkstatus(ret);
22704
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_out("okay.");
22705
1/2
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
398 box_eol();
22706 398 break;
22707
22708 default:
22709 if(!catchup)
22710 {
22711 box_out("Bad token! Searching...");
22712 box_eol();
22713 }
22714
22715 catchup=true;
22716 break;
22717 }
22718
22719
22720
1/2
✓ Branch 0 taken 11406 times.
✗ Branch 1 not taken.
11406 if(catchup)
22721 {
22722 //section id
22723 section_id=(section_id<<8);
22724
22725 if(!p_getc(&tempbyte,f))
22726 {
22727 goto invalid;
22728 }
22729
22730 section_id+=tempbyte;
22731 }
22732
22733 else
22734 {
22735 //section id
22736
3/4
✓ Branch 0 taken 11406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10949 times.
✓ Branch 3 taken 457 times.
11406 if(!pack_feof(f))
22737 {
22738
2/4
✓ Branch 0 taken 10949 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10949 times.
✗ Branch 3 not taken.
10949 if(!p_mgetl(&section_id,f))
22739 {
22740 goto invalid;
22741 }
22742 10949 }
22743 }
22744 }
22745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 }
22746 else
22747 {
22748
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22749
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22750
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22751
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22752
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22753
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22754
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22755
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22756
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22757
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22758
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22759
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22760
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22761
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "MIDIs", ID_MIDIS, [&](){ return readmidis(f, &tempheader, tunes); }},
22762
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22763
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22764
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22765
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22766 };
22767
22768 24 legacy_skip_flags = skip_flags;
22769
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22770 {
22771
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22772
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22773
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22774 {
22775 // Nothing to read.
22776
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22777 1 continue;
22778
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22779 1 continue;
22780
22781 // Haven't looked at how to skip these, because we don't need to currently: the only
22782 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22783
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22784 1 continue;
22785
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22786 1 continue;
22787
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22788 1 continue;
22789
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22790 1 continue;
22791
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22792 1 continue;
22793 9 }
22794
22795 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22796 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22797 // read all the sections even if requested to skip some.
22798 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22799 // {
22800 // if (retval == qe_cancel)
22801 // continue;
22802 // checkstatus(retval);
22803 // }
22804
22805
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22806
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22807
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22808
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22809
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22810 }
22811 24 legacy_skip_flags = nullptr;
22812
22813
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22814 {
22815
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22816
22817
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22818 {
22819 11776 int32_t type=DMaps[i].type&dmfTYPE;
22820
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22821 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22822 11776 }
22823 23 }
22824
22825
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22826
22827
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22828 23 setupsfx();
22829
22830
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22831 23 init_favorites();
22832
22833
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22834
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22835
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22836
22837
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 init_spritelists();
22838
22839 // check data
22840
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(f)
22841 {
22842
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 pack_fclose(f);
22843 804 }
22844
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 clear_quest_tmpfile();
22845
22846
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(!oldquest)
22847 {
22848
2/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 804 times.
804 if(exists(tmpfilename))
22849 {
22850 delete_file(tmpfilename);
22851 }
22852 804 }
22853
22854
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
804 if(fixffcs && combosread && mapsread)
22855 {
22856 for(int32_t i=0; i<map_count; i++)
22857 {
22858 for(int32_t j=0; j<MAPSCRS; j++)
22859 {
22860 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22861 for(int32_t m=0; m<c; m++)
22862 {
22863 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22864 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22865 }
22866 }
22867 }
22868 }
22869
22870
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if (!get_bit(skip_flags, skip_rules))
22871 {
22872
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22873
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22874
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 406 times.
480 if (should_hide)
22875
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22876
22877
3/4
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 345 times.
480 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22878 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22879 480 }
22880
22881
7/10
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 741 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
804 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22882 {
22883
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 set_qr(qr_CONTFULL_DEP, 0);
22884
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22885 62 zinit.cont_heart=100;
22886 62 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22887 62 }
22888
22889
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_out("Done.");
22890
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_eol();
22891
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 box_end(false);
22892
22893
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 481 times.
✓ Branch 3 taken 323 times.
804 if(!get_bit(skip_flags, skip_header))
22894 {
22895
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 *Header = tempheader;
22896 481 }
22897
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if(!get_bit(skip_flags, skip_zinfo))
22898 {
22899
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 ZI.copyFrom(tempzi);
22900 480 }
22901
22902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(loading_tileset_flags & TILESET_CLEARMAPS)
22903 {
22904 TheMaps.clear();
22905 TheMaps.resize(MAPSCRS*1);
22906 map_count = 1;
22907 map_infos.clear();
22908 map_infos.resize(1);
22909 }
22910
22911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 804 times.
804 if(loading_tileset_flags & TILESET_CLEARHEADER)
22912 {
22913 memset(Header->password, 0, sizeof(Header->password));
22914 memset(Header->minver, 0, sizeof(Header->minver));
22915 memset(Header->title, 0, sizeof(Header->title));
22916 memset(Header->author, 0, sizeof(Header->author));
22917 memset(Header->version, 0, sizeof(Header->version));
22918 Header->use_keyfile = 0;
22919 Header->dirty_password = false;
22920 cvs_MD5Context ctx;
22921 cvs_MD5Init(&ctx);
22922 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22923 cvs_MD5Final(Header->pwd_hash, &ctx);
22924 }
22925
22926
3/4
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✓ Branch 3 taken 324 times.
804 if (!get_bit(skip_flags, skip_maps))
22927 {
22928 // Not needed, so release its memory.
22929
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 old_combo_pages = {};
22930 480 }
22931
22932
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 480 times.
804 if (skipping_any)
22933
1/2
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
324 restore_prev_qstload_global_state();
22934
22935 804 return qe_OK;
22936
22937 invalid:
22938 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22939 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22940 box_out("error.");
22941 box_eol();
22942 box_end(true);
22943
22944 pack_fclose(f);
22945
22946 if(!oldquest)
22947 {
22948 if(exists(tmpfilename))
22949 {
22950 delete_file(tmpfilename);
22951 }
22952 }
22953
22954 restore_prev_qstload_global_state();
22955
22956 return qe_invalid;
22957
22958 804 }
22959
22960 static bool _is_loading_quest;
22961
22962 bool is_loading_quest()
22963 {
22964 return _is_loading_quest;
22965 }
22966
22967 323 std::string get_last_loaded_qstpath()
22968 {
22969 323 return last_loaded_qstpath;
22970 }
22971
22972 804 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22973 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22974 bool report, byte qst_num, dword tilesetflags)
22975 {
22976 804 loading_tileset_flags = tilesetflags;
22977 804 const char* basename = get_filename(filename);
22978 804 zapp_reporting_add_breadcrumb("load_quest", basename);
22979 804 zapp_reporting_set_tag("qst.filename", basename);
22980
22981 804 last_loaded_qstpath = filename;
22982 804 loading_qst_name = filename;
22983 804 loading_qst_num = qst_num;
22984 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22985 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22986
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (!is_ci())
22987 loadquest_report = report;
22988
22989 804 _is_loading_quest = true;
22990 804 auto start = std::chrono::steady_clock::now();
22991 804 zprint2("Loading qst: %s\n", filename);
22992 804 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22993 804 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22994 804 zprint2("Time to load qst: %d ms\n", load_ms);
22995 804 _is_loading_quest = false;
22996
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if (ret)
22997 zprint2("Error: %s\n", qst_error[ret]);
22998
22999
1/2
✓ Branch 0 taken 804 times.
✗ Branch 1 not taken.
804 if(show_progress)
23000 {
23001 if(ret)
23002 {
23003 box_out("-- Error loading quest file! --");
23004 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
23005 box_end(true);
23006 }
23007 else box_end(false);
23008 }
23009
23010 804 load_tmp_zi = NULL;
23011 804 loading_qst_name = NULL;
23012 804 loadquest_report = false;
23013 804 loading_qst_num = 0;
23014
23015 804 zapp_reporting_set_tag("qst.author", Header->author);
23016 804 zapp_reporting_set_tag("qst.title", Header->title);
23017 804 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
23018
23019 804 return ret;
23020 }
23021